process_varying_aggregation: Aggregation functions

View source: R/1_aggregate.R

process_varying_aggregationR Documentation

Aggregation functions

Description

A function to aggregate sequence data for the PROCESS study with 3 possible varying event aggregation options.

Usage

process_varying_aggregation(df, scheme = 1)

Arguments

df

A dataframe that has the sequence data and must contain columns id and date. Date must represent an index date and begin at 0.

scheme

Integer value to indicate which varying aggregation to use. Currently there are 3 options. See "Value" section for description of options.

Value

Returns a data.frame with an additional column, "period", which indicates the sequence event aggregation. The returned data.frame can be passed to pre_aggregated().

scheme = 1

Period 1 is the index data, periods 2-5 are grouped by 7 days, and periods 6+ are groubed by 30 days.

scheme = 2

Period 1 is the index data, periods 2+ are grouped by 30 days.

scheme = 3

Period 1-4 are grouped by 7 days, and periods 5+ are groubed by 30 days.

Examples


  # Creating sample data; subtracting 1 from date to create an index date
  test <- data.frame(id = 1, date = row_number(1:365), event = sample(LETTERS, 366, replace = TRUE))
  test$date = test$date - 1

  process_varying_aggregation(test, scheme = 1)


ilangurudev/approxmapR documentation built on March 22, 2022, 1:15 p.m.