Cohort Analysis
Source: R/abc.R
Database-friendly cohort analysis function. A remake of https://github.com/PeerChristensen/cohorts, combining cohort_table_month, cohort_table_year, and cohort_table_day into a single package. Rewritten for database compatibility and tested with Snowflake and DuckDB.
Usage
cohort(.data, .date, .value, time_unit = "month", period_label = FALSE)Arguments
Value
segment object
Details
-
Groups your
.valuecolumn by shared time attributes from the.datecolumn. -
Assigns each member to a cohort based on their first entry in
.date. -
Aggregates the cohort by the
time_unitargument (day,week,month,quarter, oryear). -
Computes the distinct count of each cohort member over time.