Re: [R] loop in R

2010-10-06 Thread Robert Baer
set.seed(180185) #loop: create 10 times the variables (u1,u2,u3,u4,u5) for (i in 1:10){ u1 <- c(runif(200,0,1)) u2 <- c(runif(200,0,1)) u3 <- c(runif(200,0,1)) u4 <- c(runif(200,0,1)) u5 <- c(runif(200,0,1)) u <- c(u1,u2,u3,u4,u5) mu <- matrix(u, nrow=1000, ncol=1) } As you can see, when

Re: [R] loop in R

2010-10-06 Thread David Winsemius
Is this homework? -- David. On Oct 6, 2010, at 5:51 AM, Julia Lira wrote: Dear all, I need to do a loop in R, but I am not sure the software is generating "n" times the variables I request differently. When I ask to print the last matrix created, I just can see the loop for n=1. To

Re: [R] loop in R

2010-10-06 Thread Michael Bedward
Hello Julia, Your loop is just "overwriting" your variables each time. Is this the sort of thing you want ? # make a matrix with 10 cols of N random uniform values N <- 5 x <- t( replicate( 10, runif(N, 0, 1) ) ) You can leave out the t( ... ) part if you want the randomizations to be rows inst

[R] loop in R

2010-10-06 Thread Julia Lira
Dear all, I need to do a loop in R, but I am not sure the software is generating "n" times the variables I request differently. When I ask to print the last matrix created, I just can see the loop for n=1. To be more precise, supose I need to simulate 10 times one variable and I want to fi