View source: R/aggregate_Datetime.R
aggregate_Datetime | R Documentation |
Condenses a dataset
by aggregating the data to a given (shorter) interval
unit
. aggregate_Datetime()
is opinionated in the sense that it sets
default handlers for each data type of numeric
, character
, logical
, and
factor
. These can be overwritten by the user. Columns that do not fall into
one of these categories need to be handled individually by the user (...
argument) or will be removed during aggregation. If no unit is specified the
data will simply be aggregated to the most common interval
(dominant.epoch
), which is most often not an aggregation but a rounding.)
aggregate_Datetime(
dataset,
Datetime.colname = Datetime,
unit = "dominant.epoch",
type = c("round", "floor", "ceiling"),
numeric.handler = mean,
character.handler = function(x) names(which.max(table(x, useNA = "ifany"))),
logical.handler = function(x) mean(x) >= 0.5,
factor.handler = function(x) factor(names(which.max(table(x, useNA = "ifany")))),
datetime.handler = mean,
...
)
dataset |
A light logger dataset. Expects a |
Datetime.colname |
column name that contains the datetime. Defaults to
|
unit |
Unit of binning. See |
type |
One of |
numeric.handler , character.handler , logical.handler , factor.handler , datetime.handler |
functions that handle the respective data types. The default handlers
calculate the |
... |
arguments given over to |
A tibble
with aggregated Datetime
data. Usually the number of
rows will be smaller than the input dataset
. If the handler arguments
capture all column types, the number of columns will be the same as in the
input dataset
.
#dominant epoch without aggregation
sample.data.environment %>%
dominant_epoch()
#dominant epoch with 5 minute aggregation
sample.data.environment %>%
aggregate_Datetime(unit = "5 mins") %>%
dominant_epoch()
#dominant epoch with 1 day aggregation
sample.data.environment %>%
aggregate_Datetime(unit = "1 day") %>%
dominant_epoch()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.