if (FALSE) {
## get data, prep
data(apacpwq)
dat <- apacpwq
swmpr_in <- subset(qaqc(dat), rem_cols = TRUE)
## get mean DO by quarters
aggreswmp(swmpr_in, 'quarters', params = c('do_mgl'))
## get a plot instead
aggreswmp(swmpr_in, 'quarters', params = c('do_mgl'), plot = T)
## plots with other variables
p <- aggreswmp(swmpr_in, 'months', params = c('do_mgl', 'temp', 'sal'), plot = T)
p
library(ggplot2)
p + geom_boxplot(aes(fill = var)) + theme(legend.position = 'none')
## get variance of DO by years, remove NA when calculating variance
## omit NA data in output
fun_in <- function(x) var(x, na.rm = TRUE)
aggreswmp(swmpr_in, FUN = fun_in, 'years')
}
Run the code above in your browser using DataLab