I have a kind of obvious question about doing a double loop in R and could not find the answer on this website. I am using the following code:
mu <- c(0, .2, .5, .8)
sco <- matrix(nrow = 50, ncol = 4*10)
for (mu in mus) {
for (i in 1:10) {
sco[ ,i] <- mu + rnorm(n = 50, mean = 0, sd = 1)
}
}
I am now getting 10 columns with mu + random numbers, but what I want to get is 40 columns in which the first 10 columns represent mu is 0 + random number, columns 11 to 20 represent 0.2 + random number, etc.
How do I have to modify my code in order to get these above described results?
Thank you in advance!