dt_aggregate() aggregates numeric values to a specified time unit. Columns with uniform character values are retained (i.e. patient ID, sensor name).

dt_aggregate(
  df,
  dt_field = NULL,
  unit = "5 seconds",
  floor_or_celiling = "floor",
  summary_fun = "median",
  na_rm_agg = TRUE
)

Arguments

df

a data frame with a datetime field.

dt_field

character; name of datetime field.

unit

character; string specifying a time unit or a multiple of a unit to be rounded

floor_or_celiling

character; either 'floor'(floor_date) or 'ceiling'(ceiling_date). Default = 'floor.'

summary_fun

character; summary function (i.e. 'mean', 'median'). Default = 'median.'

na_rm_agg

logical; should NA values be removed before the chosen summary_fun computes?

Value

a data frame aggregated by the specified time unit.

Examples

if (FALSE) {

dt_aggregate(df,
  dt_field = "Date_Time",
  unit = "5 seconds", floor_or_ceiling = "floor",
  summary_fun = "median", na_rm_agg = TRUE
)
}