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.5757814 -0.3053884
[[5]]
[1] 1.5117812 0.3898432 -0.6212406 -2.2146999 1.1249309
[[6]]
[1] -0.04493361 -0.01619026 0.94383621 0.82122120 0.59390132 0.91897737
[[7]]
[1] 0.78213630 0.07456498 -1.98935170 0.61982575 -0.05612874 -0.15579551
-1.47075238
[[8]]
[1] -0.47815006 0.41794156 1.35867955 -0.10278773 0.38767161 -0.05380504
-1.37705956 -0.41499456
[[9]]
[1] -0.3942900 -0.0593134 1.1000254 0.7631757 -0.1645236 -0.2533617
0.6969634 0.5566632 -0.6887557
[[10]]
[1] -0.7074952 0.3645820 0.7685329 -0.1123462 0.8811077 0.3981059
-0.6120264 0.3411197 -1.1293631 1.4330237
On Mon, Jun 22, 2009 at 5:38 AM, megh <megh700004@yahoo.com> wrote:
>
> 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 create a "list". How to modify above code?
> --
> View this message in context:
>
http://www.nabble.com/Help-on-creating-a-sequence-of-vectors-tp24144347p24144347.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
>
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
[[alternative HTML version deleted]]