huang — Jan 22, 2013, 8:15 PM
corr <- function(directory, threshold = 0) {
calc_cor <- function(id){ #calc a cor for a specified id
dat <- getmonitor(id,directory) #read
cor(dat$sulfate,dat$nitrate,use="complete.obs")
}
com <- complete(directory) # all id & nobs
id_oth <- com[com$nobs>threshold, ]$id # all id over the threshold
sapply(id_oth,calc_cor)
}