Skip to content
Prev 308925 / 398503 Next

for ( i in 23:0 ) { V <- vector [ 1 : i ] }

Hello,

Try the following.

lapply(1:23, function(i) 1:i)

As for why yuor code doesn't work, you're assigning 24 times a value to 
V, on loop exit only the last one is there. A correct way using loops 
would be


V <- list()
for(i in 1:23)
     V[[i]] <- 1:i


Beware that the last vector goes from 1 _down_ to 0.

And do read An Introduction to R, file R-intro.pdf in your R/doc directory.

Hope this helps,
Em 24-10-2012 13:25, colaiutachambers escreveu:
{ V <- vector [ 1 : i ] } "