Thursday, 23 April 2015

Importing a set of csv files and putting together in a list of data frames...

I now know how to do this.
This is the code:


# tell me where the files are
setwd("")

# give me a list of file names (it is possible to get these too)
file.list <- c("Drug1.csv", "Drug2.csv", "Drug3.csv", "Drug4.csv")

# with a loop (could be a better way), go through file.list
# read the csv file using the name in file.list
# add to a predefined list entitled data.list (created first)
# list() function in the read.csv file keeps it all together
data.list <- list()
for (i in 1:length(file.list)){
  data.list<-c(data.list, list(read.csv(file.list[i])))  
}

This seems to work which is useful.

No comments:

Post a Comment