Average multiple csv files into 1 averaged file in r -


i have approximately 300 csv files of wind speed, temp, pressure, etc, columns , each row different time 2007 2012. each file different location. want combine files 1 average of 300 files. new file have same number of rows , columns of each individual file each cell corresponding average of 300 files. there easy way this?

following this post, read files list (here i've assumed they're named weather*.csv):

csvs <- lapply(list.files(pattern="weather*.csv"), read.csv) 

all remains take average of data frames. might try like:

reduce("+", csvs) / length(csvs) 

if wanted add subset of columns, pass reduce list of data frames appropriate subset of columns. instance, if wanted remove first column each, like:

reduce("+", lapply(csvs, "[", -1)) / length(csvs) 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -