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 dataframe. If not imported by LightLogR, take care to choose a sensible variable for the Datetime.colname.

unit

Unit of binning. See lubridate::round_date() for examples. The default is "3 hours".

type

One of "round"(the default), "ceiling" or "floor". Setting chooses the relevant function from lubridate.

Datetime.colname

column name that contains the datetime. Defaults to "Datetime" which is automatically correct for data imported with LightLogR. Expects a symbol. Needs to be part of the dataset.

New.colname

Column name for the added column in the dataset.

group_by

Should the data be grouped by the new column? Defaults to FALSE

...

Parameter handed over to lubridate::round_date() and siblings

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)

[Package LightLogR version 0.3.8 Index]