I have two folders, folder1 and folder2 with around 200 files each that are either *rda or *R. I want to read all of the files and datasets from the two directories. How can I do that?
Paths for:
folder1: C:\folder1
folder2: C:\folder2
My trial
setwd("C:/folder1")
myls <- ls() # do work as this will only list that are already loaded in the system
setwd("C:/folder2")
myls2 <- ls()
myls # do work as this will only list that are already loaded in the system
I know this is simple question, but I do not have any answer.
Since
.rdarequiresloadand.Rrequiressource, I would do something like this:Update for reading from multiple folders at once
Notice also the use of
$at the end of the search pattern, to make sure it matches only, say, a.Rat the end of a line, and the use ofignore.casein case some of the files are named, say,script.r.