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 I print(mu), I just can see a matrix with the vector
u in one column. I also tried to increase the number of columns to 10 (or
i), but the matrix will have 10 times the same vector. And what I need is
like a Monte Carlo simulation, where I have to simulate 10 times the
variables above.
Am I doing something wrong?
Yes. You are not using the indexing variable, i, of the for loop to change
anything each time through the loop.
.
______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.