View source: R/subhourly2nminutes.R
subhourly2nminutes | R Documentation |
Generic function for aggregating a sub-hourly time series into a "n-minutes' one.
subhourly2nminutes(x, ...)
## Default S3 method:
subhourly2nminutes(x, nminutes, FUN, na.rm=TRUE,
from=start(x), to=end(x), ...)
## S3 method for class 'zoo'
subhourly2nminutes(x, nminutes, FUN, na.rm=TRUE,
from=start(x), to=end(x), ...)
## S3 method for class 'data.frame'
subhourly2nminutes(x, nminutes, FUN, na.rm=TRUE,
from=start(x), to=end(x), dates=1, date.fmt="%Y-%m-%d %H:%M:%S",
out.fmt="zoo", verbose= TRUE, ...)
## S3 method for class 'matrix'
subhourly2nminutes(x, nminutes, FUN, na.rm=TRUE,
from=start(x), to=end(x), dates=1, date.fmt="%Y-%m-%d %H:%M:%S",
out.fmt="zoo", verbose= TRUE, ...)
x |
zoo, data.frame or matrix object, with sub-hourly time series. |
nminutes |
numeric, defining the amount of minutes to be used for aggregating |
FUN |
Function that have to be applied for aggregating from sub-hourly into n-minutes time step. (e.g., for precipitation |
na.rm |
Logical. Should missing values be removed? |
from |
POSIX object indicating the starting time used to carry out the temporal aggregation. |
to |
POSIX object indicating the ending time used to carry out the temporal aggregation. |
dates |
numeric, factor, POSIXct or POSIXt object indicating how to obtain the dates and times for each column of |
date.fmt |
character indicating the format in which the dates are stored in |
out.fmt |
OPTIONAL. Only used when |
verbose |
logical; if TRUE, progress messages are printed |
... |
further arguments passed to or from other methods. |
a zoo object with hourly time series
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
subhourly2hourly
, subdaily2daily
, subdaily2monthly
, subdaily2annual
, subdaily2seasonal
, as.POSIXct
, dm2seasonal
, monthlyfunction
, seasonalfunction
, hydroplot
, vector2zoo
, izoo2rzoo
## Creating a 5-min time sequence and counting its length
dt <- seq( from=as.POSIXct("2021-06-30 00:00"), to=as.POSIXct("2021-06-30 23:55"), by="5 min" )
ndt <- length(dt)
## Creating a dummy 5-min zoo object, with 1 as the only value in each time period
x <- zoo( rep(1, ndt), dt)
## Aggregation from 5-minute single ts into 10-minute ts
h1 <- subhourly2nminutes(x, nminutes= 10, FUN=sum, na.rm=TRUE)
## Aggregation of 3 ts with 5-minute time frequency (i.e., a zoo matrix)
## into a 30-minute zoo object.
X <- cbind(x, x, x)
h2 <- subhourly2nminutes(X, nminutes= 30, FUN=sum, na.rm=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.