2
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 give values normally distributed 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 was at the end k*m (the number of rounds * the sample generated in each one).
UPDATING
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 have managed to generate everything I needed in k different data.frames, the problem is to unite all Dfs.
Seems to work
– Pedro Cavalcante