Calculate daily means from 5-minute interval data
On Thu, 2 Sep 2021, Andrew Simmons wrote:
You could use 'split' to create a list of data frames, and then apply a
function to each to get the means and sds.
cols <- "cfs" # add more as necessary
S <- split(discharge[cols], format(discharge$sampdate, format = "%Y-%m"))
means <- do.call("rbind", lapply(S, colMeans, na.rm = TRUE))
sds <- do.call("rbind", lapply(S, function(xx) sapply(xx, sd, na.rm =
TRUE)))
Andrew, Thank you for the valuable lesson. This is new to me and I know I'll have use for it in the future, too. Much appreciated! Stay well, Rich