Using array in R for reading data with read.csv from multiple sources -


so trying load multiple csv files project , figured use 1 array, data_in, csv files can reference them

data_in[,,1] ##first csv file data_in[1,,2] ## first row of second csv file 

and on. read files have loop.

for (i in seq_along(names)) {     file_name <- paste(names[i],".csv", sep = "")     data_in[,,i] <- read.csv(file_name, header=t, sep= ",")     } 

but wouldn't here if worked. i'm not used r need declare dimensions of data_in before load in data? there way read data in using index csv file or have use 3d array? sorry if sort of basic.

any appreciated. have nice day.

to expand on hugh's comment. want list.files() , lapply read files in list of data.frames can access using [[]]

files <- list.files(pattern="csv") data_in <- lapply(files, read.csv) 

read.csv read.table header = t , sep ="," default don't need specify them.

then access them use [[]] e.g.

head(data_in[[1]]) 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -