R 3.0.3 rbind multiple csv files

R 3.0.3: I have 40 csv files all structured in the same way as I want rbindin a single file, so I can calculate the average value for one column.

I was looking for:

  • This site
  • R in a Nutshell
  • R_Intro sources
  • ?rbind Help in RStudio

I can not find the answer.

Any suggestions / pointers?

+4
source share
2 answers

Using the answer here [ Import multiple files and index them ]

a list of files with the extension .csv - this assumes that the only .csv files in your working directory are the ones you want to read

files  <- list.files(pattern = '\\.csv')

read files to list - are there any headers?

tables <- lapply(files, read.csv, header = TRUE)

rbind files

combined.df <- do.call(rbind , tables)

- ,

s <- sapply(combined.df, is.numeric)

colMeans(combined.df[s])
+11

plyr:

files <- list.files(...)
data <- adply(files, 1, read.table)

( : , )

0

Source: https://habr.com/ru/post/1537192/


All Articles