Consider the use of a 'list' so you don't clutter up the global enviroment
with a lot of objects that you might forget about:
> vec <- lapply(1:10, rnorm)
> vec
[[1]]
[1] -0.6264538
[[2]]
[1] 0.1836433 -0.8356286
[[3]]
[1] 1.5952808 0.3295078 -0.8204684
[[4]]
[1] 0.4874291 0.7383247 0.575781
megh:
> I want to create a number of vectors like :
>
> vec1 <- rnorm(1)
> vec2 <- rnorm(2)
> vec3 <- rnorm(3)
>
> and so on...
Maybe try the assign() function. Something like:
for (i in 1:10) assign ( paste ( "vec" , i , sep = "" ) , rnorm(i) )
Kind regards, Nikos
I want to create a number of vectors like :
vec1 <- rnorm(1)
vec2 <- rnorm(2)
vec3 <- rnorm(3)
and so on...
Here I tried following :
for (i in 1:10) paste("vec", i, sep="") <- rnorm(i)
However obviously that is not working. Here vectors I need to be seperated
i.e I do not want to cre
3 matches
Mail list logo