0

I have 9 data frames here, data01 to data09. My question is, how to get the column names of each data frame using for loop in r? The paste syntax didn't work.

for (i in 1: 9) {
  print(colnames(paste("data0", i, sep = "")))
}
  • How did you create these 9 data frames in the first place? If you have related data it's easier to work with them in R if you store them in a named list. Then you can easily apply functions over that list. `paste()` will just return a string. Strings are different than actual variable names. – MrFlick Feb 24 '22 at 04:03
  • thank you very much! I have solved it. just use get() . – Wikiwang Mar 07 '22 at 08:32

0 Answers0