Skip to content

summing 15 minute precip data to daily

4 messages · Janet Choate, Joshua Wiley, stephen sefick +1 more

#
Hi Janet,

One relatively simple way would be to transofrm the data into a 96 x
Ndays matrix and use colSums().  Of course, lets say on one day, the
measurement tool had technical difficulties and missed two
observations, then you only have 94 observations for that day, you
will need a fancier solution that deals with time not number of
observations.  Below is an example.

Cheers,

Josh


## Imaginary precipitation data for 7 days
set.seed(10)
x <- rnorm(96*7, 1, .1)
## An alternate way you may have the data stored
xalt <- data.frame(precip = x)

## Assuming _no_ missing observations
colSums(matrix(x, nrow = 96))

## alternate version
colSums(matrix(xalt$precip, nrow = 96))
On Thu, Feb 17, 2011 at 11:56 AM, Janet Choate <jsc.eco at gmail.com> wrote:

  
    
#
Janet:

The zoo package and aggregate.zoo should do the trick.  I have done this
many times with these tools.
HTH,

Stephen
On Thu, 2011-02-17 at 11:56 -0800, Janet Choate wrote:
#
On Thu, Feb 17, 2011 at 3:39 PM, Stephen Sefick <ssefick at gmail.com> wrote:
Here is some code. Suppose precip is the data.  We convert it to a zoo
object with date/times assuming the first one is at the start of
2000-01-01.  Then we aggregate them by day:
2000-01-01 2000-01-02 2000-01-03
      4656      13872       1572