Create array of for loop results – General

Hello,

I’m loading 20 files into R using the below script (they’re matrices of 500 x 500). I would like create an array of all the loaded files. is there a way I can have R do it automatically?

##Read files names
filenames <- list.files(path="/Users/dana........")

###Load all files
for(i in filenames){
  filepath <- file.path("/Users/dana........", paste(i))
  assign(i, read.delim(filepath,
                       colClasses=c(rep("numeric",500)),
                       header = FALSE,
                       sep = ";"))
}

Read more here: Source link

Tagged