0

I am reading some files into R with a "for loop" and naming them based on the looping index. I have used the assign fucntion to dynamically name one data frame for each file being read as follows:

for (i in 1:10){
    assign(paste0("df",i),read_csv(paste0("file",i,".csv")))
}

This works fine. However, while inside the for loop, I also want to do some other operations to the data frame, but I dont know how to refer to it given that the name is changing as the loop progresses.
I want to add to the loop something along the lines of:

names(paste0("df",i)) <- make.names(names(paste0("df",i)))

I want to execute the above command but I don't know how to properly pass the changing data frame name to the names() function.

Thanks in advance,

MR

Mario Reyes
  • 385
  • 1
  • 2
  • 13

0 Answers0