0

i want to load data into my R working environment from a folder that has Group1.csv, Group2.csv, …, Group10.csv. what is the tricky part is I want to apply names to each of the group, like shown below:

diet_group1 <- read_csv(diet_groups[1])
diet_group2<- read_csv(diet_groups[2])  etc

diet_group10<- read_csv(diet_groups[10])


diet_groups<- list.files(pattern = "\\.csv")# , ,TRUE)

how can I do this with one code? thanks, Lil

1 Answers1

0
 temp <- list.files(pattern="*.csv")
 temp
 for (i in 1:length(temp)) {
         assign(paste(gsub(".csv", x=temp[i], replacement = "")), read.csv(temp[i]))
       }

This worked for my assignment