Hi Francesca,
> for(i in 1:length(x1<-c(100,1000,1))){
j<-x1[i]
x1[i]<-mean(j)
}
> x1
[1] 100 1000 1
A.K.
- Original Message -
From: Francesca
To: r-help@r-project.org
Cc:
Sent: Friday, May 18, 2012 10:59 AM
Subject: [R] How to fix indeces
l Message -
> From: Francesca
> To: r-help@r-project.org
> Cc:
> Sent: Friday, May 18, 2012 10:59 AM
> Subject: [R] How to fix indeces in a loop
>
> Dear Contributors,
> I have an easy question for you which is puzzling me instead.
> I am running loops similar to th
Hi Francesca,
Here's one approach:
loopvalues <- c(100,1000,1)
results <- numeric(length(loopvalues))
for(loopindex in 1:length(loopvalues)) {
i <- loopvalues[loopindex]
results[loopindex] <- mean(i)
# assuming your intent is actually something other
# than ta
Dear Contributors,
I have an easy question for you which is puzzling me instead.
I am running loops similar to the following:
for (i in c(100,1000,1)){
print((mean(i)))
#var<-var(rnorm(i,0,1))
}
This is what I obtain:
[1] 100
[1] 1000
[1] 1
In this case I ask the software to print out
4 matches
Mail list logo