Change variable name in for loop using R -
i have loop:
for (i in 1:10){ ai=d+rnorm(3)} what have a1, a2,a3...a10 , have variable i in variable name.
it doesn't work way, i'm missing small thing. how can use i in loop assign different variable names?
d <- 5 for(i in 1:10) { nam <- paste("a", i, sep = "") assign(nam, rnorm(3)+d) }
Comments
Post a Comment