col1 <- c(1, 2, 3) col2 <- c(4, 5, 6) col3 <- c(7, 8, 9)
data.frame(col1, col2, col3)
gives<
You may want to use mget
mget
do.call(cbind, mget(paste0("col", 1:3)))
Where the paste0 generates the variable names, mget gets the associated values, and cbind puts them together into a data frame.
paste0
cbind