creating vector os zeros for simulations (beginner's question)
you could try this: u2=matrix(rnorm(150), nrow=5, ncol=30); u2 Seb
On Thu, Oct 27, 2011 at 1:44 PM, Iara Faria <iaragohn at yahoo.com.br> wrote:
Dear R helpers,
I know this is a simple task, but I'm new to R and I'm still havind difficulties with the language.
I want to create 30 vectors to be used in a simulation, each?with 1 columm and 5 lines, of random numbers N(0,1).
What I tried was this:
N=150
u2<-rep(1:150,0)
u2<-list(matrix(0,5))
u2
for(i in 1:N)
{
u2[i]<-rnorm(5)
}
u2
### also tried this:
N=150
u2<-rep((matrix(0,5)),30)
u2
for(i in 1:N)
{
u2[i]<-rnorm(5)
}
u2
The problem is none of this gives me the random numbers arranged in vectors.
I've tried other variations too, but haven't managed to get it through.
Any help is very welcome.
Kind regards,
Iara
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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 and provide commented, minimal, self-contained, reproducible code.