Off topic:Loading multiple RDS files save in the same directory using R
0
0
Entering edit mode
4.7 years ago
clementpch • 0

Hi Everyone,

I'm trying to load multiple .rds files that are save in the same directory. I have made a function for that and I iterate on a list of the files dir to load it but it doesn't work, see below that I write:

markerDir="..."

markerFilesList <- list.files(markerDir,pattern = ".rds", recursive = TRUE, include.dirs = TRUE)

readRDSfct <- function(markerFilesList,markerDir,i){
  print(paste0("Reading the marker file called :",basename(markerFilesList[[i]])))
  nameVariableTmp=basename(markerFilesList[[i]])
  nameVariable=gsub(pattern = "\\.rds", '',nameVariableTmp)
  print(paste0("file saved in varibale called:", nameVariable))
  currentRDSfile = readRDS(paste0(markerDir,markerFilesList[[i]])) #nameVariable
  return(currentRDSfile)
}

for (i in 1:length(markerFilesList)){
 readRDSfct(markerFilesList, markerDir, i)
}

Does anyone has a suggestion for me to do it ?

thanks in advance!

R • 1.3k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2872 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6