Danah
January 29, 2023, 2:37pm
1
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 files names
filenames <- list.files(path="/Users/dana........")
###Load all files
my_list_of_results <- lappy(filenames,
function(i){
read.delim( file.path("/Users/dana........", paste(i)),
colClasses=c(rep("numeric",500)),
header = FALSE,
sep = ";")})
1 Like
Danah
January 31, 2023, 12:02pm
3
Perfect, thank you so much!
system
Closed
February 7, 2023, 12:03pm
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.