aggregate_sequences: Aggregation functions

View source: R/1_aggregate.R

aggregate_sequencesR Documentation

Aggregation functions

Description

A dataframe having id, date and event column can be aggregated using this function

Usage

aggregate_sequences(unaggregated_data, format = "%m-%d-%Y", index_date = FALSE,
  calendar = FALSE, unit = "week", n_units = 1, anchor_table = NA,
  anchor_vector = NA, base_date = NA, occurence = min, multiset = FALSE,
  include_date = FALSE, summary_stats = TRUE, output_directory = "~")

Arguments

unaggregated_data

A dataframe that has exactly 3 columns in this order - id, date, event

format

String specifying format of the date

index_date

Logical indicator which indicates if the data is in a numerical format which represents the number of days since an index event, i.e. 0 represents first date, 1 respresents 1 day since index date (0), 2 represents 2 days since index date (0), etc.

calendar

Boolean indicating whether or not to use calendar aggregation. Defaults to false

unit

String specifying unit of aggregation. Takes one of c("day", "week", "month", "6 months", "year")

n_units

Integer specifying number of units.

anchor_table

Beta

anchor_vector

Beta

base_date

Beta

occurence

Beta

multiset

Beta; Logical indicator which controls the exclusion of multiple events within the same event set.

include_date

Logical indicator which controls the inclusion of the date variable in the returning data. If creating reports using the -generate_reports- function of approxmapR, then the dates will be included in the alignment_with_date output file if this argument is equal to TRUE - default value is FALSE.

summary_stats

Logical controlling printing of summary statistics regarding aggregation. Defaults to TRUE

output_directory

The path to where the exports should be placed.

Value

Aggregated dataframe that has sequence id, itemset (period) and event (item)

Examples

library(approxmapR)

data("mvad")

# This will aggregate the data using a 6-month frame, i.e. all events which occurred
#   in 6-months will be grouped into an event set
mvad %>% aggregate_sequences(format = "%Y-%m-%d", unit = "month", n_units = 6)

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