I need to separate csv files into their own dataframes using R.
Currently, I'm using:
file_names <- list.files(path = my_path,recursive = TRUE)
for(i in file_names){file <- read.csv(i)}
However, I want each file in it's own dataframe so I can total each one before binding them. I was trying to use lapply:
file_names <- list.files(path = my_path, recursive = TRUE)
file <- lapply(file_names,read.csv)
names(file) <- c("a","b","c","d","e","f","g")
but the number of files will sometimes be different. Sometimes there could be less files. How can I read the files into separate dataframes before combining them?