I have folder with 100 csv files that I want to read in R. The csv files are located in folder C:/test/data/
. Here's what I am doing:
setwd("C:/test/")
temp <- list.files(path=paste0(getwd(),"/data/"), pattern="*.csv")
named.list <- lapply(tmin.temp, read.csv)
The issue is that I do not want to change my working directory (I want to keep the working directory C:/test/
). So the second line of code throws up an error since read.csv
cannot find my csv files in my working directory. I also tried doing this:
temp <- list.files(path=paste0(getwd(),"/data/"), pattern="*.csv")
named.list <- lapply(tmin.temp, read.csv(path=paste0(getwd(),"/data/"))
But this generates an error since the read.csv
does not take this kind of argument. I can always write a for
loop to read all files but I am looking for a solution that corrects the above approach.
Thank you.