Tools for creating and working with data cohorts, which are groups of respondents sharing common characteristics.
Installation
# Install from internal CRAN
install.packages("g6tr.cohorts")Features
The package provides functionality for:
- Creating individual cohorts with
create_cohort() - Creating sets of cohorts based on grouping variables with
create_cohort_set()
Example Data
The package includes an example dataset (example_data) with 500 simulated survey respondents that can be used to explore the functionality:
# View the structure of the example data
str(example_data)Example
library(g6tr.cohorts)
library(dplyr)
# Create a cohort for US respondents
us_cohort <- example_data |>
filter(country == "US") |>
create_cohort(
id_col = response_id,
weight_col = weight
)
# Create a set of cohorts by groups
cohort_set <- example_data |>
create_cohort_set(
id_col = response_id,
grp_cols = c(country, age_group),
population = TRUE,
weight_col = weight
)Documentation
For more detailed examples and usage, see the package vignettes:
vignette("introduction", package = "g6tr.cohorts")