My goal is to import all txt files from a specific folder into a list.
So I:
setwd(".../folder") data <- list.files(pattern = "\\.txt$") lis <- lapply(data, read.csv)
However, I would like to avoid using setwd() . Therefore, I can do:
data <- list.files(path = ".../folder", pattern = "\\.txt$")
But then, of course, I get an error message. There is no such file or directory that read.csv looks in the wrong directory. How can I specify a folder in combination with importing all files into data ?
source share