I want to import a folder to R. This folder's name is Plan1 and in this folder there are 3 subfolders .in all subfolders there are some RData files. These RDatas are data and some functions which have been saved. I want to import the whole Plan1 at the same time to R.
I wanna know, is it possible? and can you help me to write code for that? THANK YOU in advance.
Try this, which makes a vector called rda_files
of all the .rda files by looking through "/some/folder/"
and all its subdirectories (folders in folders). Then uses purrr::walk
to load them all into your env.
folder <- "/some/folder/" # e.g. "~/Desktop/my_folder/
rda_files <- list.files(folder, recursive = TRUE, pattern = ".rda$")
purrr::walk(paste0(folder,rda_files), ~ load(.x, .GlobalEnv))