How to read multiple files using for loop and numfiles using temp?
Answers
Answered by
0
For reading multiple files for a loop I would put all the CSV files in a directory, create a list and do a loop to read all the csv files from the directory in the list.
setwd("~/Documents/")
ldf <- list() # creates a list
listcsv <- dir(pattern = "*.csv") # creates the list of all the csv files in the directory
for (k in 1:length(listcsv)){
ldf[[k]] <- read.csv(listcsv[k])
}
str(ldf[[1]])
Reading a file in a temporary directory is done in exactly the same way as non-temporary files are read.
getAbsolutePath() returns the absolute path name of the file. If by "file name" you refer to just the "file" portion of the path name, use the getName() method.
✌
Similar questions