[Solved] Calculate the mean of one column from several CSV files
You do not need more functions. The solution can be simpler from my understanding in 6 lines: pollutantmean <- function(directory, pollutant, id = 1:10) { filenames <- sprintf(“%03d.csv”, id) filenames <- paste(directory, filenames, sep=”https://stackoverflow.com/”) ldf <- lapply(filenames, read.csv) df=ldply(ldf) # df is your list of data.frames mean(df[, pollutant], na.rm = TRUE) } 2 solved Calculate … Read more