What code do I need to read multiple data sets into R ?
For a single dataset I use:
File <- read.csv("C:\MyFile.CSV", header=T)
But I need to compare up to 20 different datasets.
Thanks in advance !
What code do I need to read multiple data sets into R ?
For a single dataset I use:
File <- read.csv("C:\MyFile.CSV", header=T)
But I need to compare up to 20 different datasets.
Thanks in advance !
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]])