I'm looking to loop through 4 different folders of CSV files, assign them to different objects, and use all 4 data frames in a later function. All folders have the same number of CSV files (400).
milk_contents <- list.dir(milk folder)
cereal_contents <- list.dir (cereal)
OJ_contents <- list.dir(OJ)
cat_contents <- list.dir(cat)
milk_loc <- "C/Desktop/milk"
cereal_loc <- "C/Desktop/cereal"
OJ_loc <- "C/Desktop/OJ"
cat_loc <- "C/Desktop/cat"
something like:
for(sheet in milk){
milk_sheet <- read.csv(paste0(milk_loc,"/",sheet),stringasfactors = false)
for(file in cereal){
cereal_file <- read.csv(paste0(cereal_loc,"/",file),stringasfactors = false)
for(cup in OJ){
OJ_cup <- read.csv(paste0(OJ_loc,"/",cup),stringasfactors = false)
for(paw in cat){
cat_paw <- read.csv(paste0(cat_loc,"/",paw),stringasfactors = false)
ex_function(milk_sheet, cereal_file, OJ_cup, cat_paw)
}}}}
I'm thinking there's probably a more elegant solution out there -