mode_calculation: Calculates the most common duration between purchases

View source: R/mode_calculation.R

mode_calculationR Documentation

Calculates the most common duration between purchases

Description

Calculates the mode of time intervals between purchases for each package. Intervals within 2 days are grouped together. The most common (modal) interval is selected from the grouped values. If multiple modes exist, the one closest to the median is chosen; if there's still a tie, the one closest to the mean is selected. Intended for internal use in the PRE2DUP-R package.

Usage

mode_calculation(pack_id, pre_ratio, dur, report_iters = 50)

Arguments

pack_id

vector of package identifiers

pre_ratio

vector of package ratios, i.e. number of packages because partial packages are not allowed

dur

vector of times between purchases

Value

data.table with the most common duration between purchases


piavat/PRE2DUP-R documentation built on June 11, 2025, 11:42 a.m.