k <- 8
m = 100
for (i in 1:k){
x <- rnorm(mean = i,
sd = .5,
n=m)
y <- rnorm(mean = (8-i),
sd = .5,
n=m)
amostra2 <- data.frame(x,y)
}
This is the code I have. Given k and m, I generate normally distributed values and save them in a data frame. The problem is that this way the loop only rewrites the values of x and y, when I wanted to "append" them, so that the length of each vector is at the end k * m (the number of rounds * the sample generated in each ).
UPDATE
for (i in 1:k){
x <- rnorm(mean = i,
sd = .5,
n=m)
y <- rnorm(mean = (8-i),
sd = .5,
n=m)
assign(paste("amostra_for_",i, sep=""),
value = data.frame(x,y))
}
for (i in 2:k) {
amostra2 <- rbind(amostra_for_1,
paste("amostra_for_",i))
}
Now I was able to generate everything I needed in different data.frames k, the problem is to merge all the DFs.