Skip to content
Back to formatted view

Raw Message

Message-ID: <alpine.LNX.2.20.2109021230300.18288@salmo.appl-ecosys.com>
Date: 2021-09-02T19:31:40Z
From: Rich Shepard
Subject: Calculate daily means from 5-minute interval data
In-Reply-To: <CAPcHnpRJ9LUOTYx+Yf-w1j3wu9=XcGEjUj2-1DB82vu9oy9PoA@mail.gmail.com>

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