1

I'm using R. I have very many files in .csv format which I would like to read and then combine them into a data frame with each file representing a column, so that I can manipulate using simple statistics. How can I go about this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Frank5622
  • 11
  • 2
  • Once you imported the files, follow [R - list to data frame](https://stackoverflow.com/questions/4227223/r-list-to-data-frame) – markus Dec 07 '18 at 09:04

2 Answers2

0

Assuming that files contains the list of your files,

ff <- sapply(files, read.csv)
df <- Reduce(cbind, ff)

First command loads all files. Second command merges all files into one data frame. Clearly, I am assuming that all files have one column and the same number of rows. You can check that with

sapply(ff, nrow)
sapply(ff, ncol)
January
  • 16,320
  • 6
  • 52
  • 74
0
Data<-do.call(rbind,lapply(filelist,read.csv))
Jack Hsueh
  • 115
  • 8