cut_Datetime {LightLogR} | R Documentation |
Create Datetime bins for visualization and calculation
Description
cut_Datetime
is a wrapper around lubridate::round_date()
(and friends)
combined with dplyr::mutate()
, to create a new column in a light logger
dataset with a specified binsize. This can be "3 hours"
, "15 secs"
, or
"0.5 days"
. It is a useful step between a dataset and a visualization or
summary step.
Usage
cut_Datetime(
dataset,
unit = "3 hours",
type = c("round", "floor", "ceiling"),
Datetime.colname = Datetime,
New.colname = Datetime.rounded,
group_by = FALSE,
...
)
Arguments
dataset |
A light logger dataset. Expects a |
unit |
Unit of binning. See |
type |
One of |
Datetime.colname |
column name that contains the datetime. Defaults to
|
New.colname |
Column name for the added column in the |
group_by |
Should the data be grouped by the new column? Defaults to |
... |
Parameter handed over to |
Value
a data.frame
object identical to dataset
but with the added
column of binned datetimes.
Examples
#compare Datetime and Datetime.rounded
sample.data.environment %>%
cut_Datetime() %>%
dplyr::slice_sample(n = 5)