I guess this is a bit of a beginner's question but I haven't quite found an answer or figured out what I'm doing wrong.
I'm trying to read 20 CSV files that are stored in a separate directory using:
setwd("./Data")
filenames <- list.files()
All <- lapply(filenames,function(i){
i <- paste(".\\",i,sep="")
read.csv(i, header=TRUE, skip=4)
})
And I get the following error:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '.\filename.csv': No such file or directory
Where filename stand for the name of the first file in my folder.
Thanks in advance!
Try just removing the: i <- paste(".\\",i,sep="")
read.csv should work fine with the list.files(full.names=TRUE)
output
setwd("./Data")
filenames <- list.files(full.names=TRUE)
All <- lapply(filenames,function(i){
read.csv(i, header=TRUE, skip=4)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With