Description Usage Arguments Details Author(s) Examples
Performs an aggregation within the interval defined by freq
, by executing
a provided function.
1 | make.aggregation(df, freq, fun)
|
df |
a dataframe, the first column must be the time index. |
freq |
frequency of the observations in the dataframe, same as |
fun |
a function like |
For security reasons the dataframe must have a number of observations multiple
of freq
, also all the time index must be complete i.e without silents losts, see
fortify_df
for achieve this.
Its desirable that the time interval present in the input dataframe include complete periods of time. For example
if the time index (first column), takes the range ['2019/01/01 00:00:00', ..., '2019/01/03 20:00:00'] will be more
convenient to modify it to ['2019/01/01 00:00:00', ..., '2019/01/03 23:00:00'] for obtain the last day completely,
that effect can be acomplish with the function fortify_df
, using the parameter fInterval
.
JV Yago
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Mean of 3 day data by days
a = as.POSIXct("2019/01/01", tz = "UTC")
b = as.POSIXct("2019/01/03 23:00:00", tz = "UTC")
df <- data.frame(dates = seq.POSIXt(a,b,"hour"), A = runif(24*3))
make.aggregation(df, freq = 24, mean)
# The same with multicolumn datadrame
a = as.POSIXct("2019/01/01", tz = "UTC")
b = as.POSIXct("2019/01/03 23:00:00", tz = "UTC")
df<-data.frame(dates = seq.POSIXt(a,b,"hour"),
A = runif(24*3),
B = rep(1:3,each=24))
make.aggregation(df, freq = 24, mean)
# The previus example but using a 12 hour mean
a = as.POSIXct("2019/01/01", tz = "UTC")
b = as.POSIXct("2019/01/03 23:00:00", tz = "UTC")
df<-data.frame(dates = seq.POSIXt(a,b,"hour"),
A = runif(24*3),
B = rep(1:3,each=24))
make.aggregation(df, freq = 12, mean)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.