I have several csv files (let say A.csv, B.csv, ...) in several folders let say (F1, F2,...). I want to read all files in a way that cbind A.csv, B.csv of each folder and create main dataframe for each folder. It means I need to have n dataframe for my n folders with a unique name based on folder name.
I have tried this code to get the list of csv files.
files <- dir("/Users/.../.../...", recursive=TRUE, full.names=TRUE, pattern="\\.csv$")
then created a function:
readFun <- function(x) { df <- read.csv(x)}
then sapply:
sapply(files, readFun)
it returns this error:
Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input
I played around with the code alot, but did not figure out how to debug it. Any help is highly appreciated.
Also, any hint on how to create main dataframe for each folder?
Thanks