In my data.frame I want to add automatically some variabeles inside a loop. For instance "abc_1", "abc_2", "abc_3".
data.frame:
x <- c(1,2,3)
y <- c(4,5,6)
test<- data.frame("V1"=x, "V2"=y)
formula to create new variables:
for (i in 1:3){
paste("test$abc",i,sep="") <- 5
}
Maybe the loop isn't the best method, but ok. So on the left side of the formula in the loop I try to concatenate 3 variables based on the "i" and some text. But paste doesn't work. Anybody got a bether idea?
[or may betest[paste0("abc", 1:3)] <- 5