Package 'cohorts'

Title: Cohort Analysis Made Easy
Description: Functions to simplify the process of preparing event and transaction for cohort analysis.
Authors: Peer Christensen [aut, cre]
Maintainer: Peer Christensen <[email protected]>
License: MIT + file LICENSE
Version: 1.2.0
Built: 2025-02-20 03:13:59 UTC
Source: https://github.com/peerchristensen/cohorts

Help Index


Create a Cohort Table Using Day Level Event Data

Description

Creates a cohort table with day level event data with rows corresponding to cohort numbers and columns as dates.

Usage

cohort_table_day(df, id_var, date)

Arguments

df

Dataframe

id_var

ID variable

date

Date

Value

Cohort table

Examples

cohort_table_day(gamelaunch, userid, eventDate)

Create a Cohort Table Using Month Level Event Data

Description

Creates a cohort table with month level event data with rows corresponding to cohort numbers and columns as months.

Usage

cohort_table_month(df, id_var, date)

Arguments

df

Dataframe

id_var

ID variable

date

Date

Value

Cohort table

Examples

cohort_table_month(online_cohorts, CustomerID, InvoiceDate)

Convert Values of a Cohort Table to Percentages

Description

Converts values of a cohort table to percentages of initial cohort sizes.

Usage

cohort_table_pct(cohort_table, decimals = 1)

Arguments

cohort_table

Cohort table

decimals

Integer

Value

Cohort table

Examples

online_cohorts %>%
cohort_table_month(CustomerID, InvoiceDate) %>%
cohort_table_pct(decimals = 1)

Create a Cohort Table Using Week Level Event Data

Description

Creates a cohort table with week level event data with rows corresponding to cohort numbers and columns as dates.

Usage

cohort_table_week(df, id_var, date)

Arguments

df

Dataframe

id_var

ID variable

date

Date

Value

Cohort table

Examples

cohort_table_week(gamelaunch, userid, eventDate)

Create a Cohort Table Using Year Level Event Data

Description

Creates a cohort table with year level event data with rows corresponding to cohort numbers and columns as dates.

Usage

cohort_table_year(df, id_var, date)

Arguments

df

Dataframe

id_var

ID variable

date

Date

Value

Cohort table

Examples

cohort_table_week(gamelaunch, userid, eventDate)

Event Data From the Launch of a Mobile Game

Description

A dataset containing 29324 observations with three columns: userid, eventDate and eventName.

Usage

gamelaunch

Format

A data frame with 29324 rows and 3 variables:

userid

User ID

eventDate

Event Date

eventName

Event Name

...


Order Data From an Online Store

Description

A dataset containing 19573 observations with two columns: CustomerID and InvoiceDate

Usage

online_cohorts

Format

A data frame with 19,573 rows and 2 variables:

CustomerID

Customer ID

InvoiceDate

InvoiceDate

...


Left-shift a Cohort Table

Description

Left-shifts a cohort table

Usage

shift_left(cohort_table)

Arguments

cohort_table

Cohort table

Value

Cohort table

Examples

online_cohorts %>%
cohort_table_month(CustomerID, InvoiceDate) %>%
shift_left()

Left-shift a Cohort Table With Cohort Sizes as Percentages

Description

Left-shifts a cohort table with cohort sizes as percentages of start sizes.

Usage

shift_left_pct(cohort_table, decimals = 1)

Arguments

cohort_table

Cohort table

decimals

Integer

Value

Cohort table

Examples

online_cohorts %>%
cohort_table_month(CustomerID, InvoiceDate) %>%
shift_left_pct()