Skip to content

Instantly share code, notes, and snippets.

@cimentadaj
Last active August 29, 2015 14:04
Show Gist options
  • Save cimentadaj/71d5b94da09ffc9f5725 to your computer and use it in GitHub Desktop.
Save cimentadaj/71d5b94da09ffc9f5725 to your computer and use it in GitHub Desktop.
pollutantmean <- function(directory, pollutant, id = 1:332) {
data.files <- list.files(directory, full.names = T)
alldata <- data.frame()
for(i in 1:332) {
alldata <- rbind(alldata, read.csv(data.files[i]))
}
datasubset <- subset(alldata[,"sulfate"] == pollutant && alldata[,"nitrate"] == pollutant && alldata[,"ID"] = id )
mean(datasubset$pollutant, na.rm = T)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment