Skip to contents

brand_summarize_funnel() returns one row per brand, or one row per brand-cohort combination, with weighted funnel summaries packed across all stored funnel stages.

Usage

brand_summarize_funnel(
  brand,
  which = c("counts", "percentages", "sequential"),
  cohort = NULL
)

Arguments

brand

A g6tr_brand object created with brand_create().

which

Character vector selecting which funnel summaries to compute. Supported values are "counts", "percentages", and "sequential".

cohort

Optional cohort or cohort set. When supplied, summaries are restricted to those IDs and use brand$data$weight * cohort$weight.

Value

A tibble with columns brand, n, weighted_n, and packed funnel summaries. If NPS is attached, a packed nps summary is also included. When cohort_set is supplied, the non-list cohort metadata columns are preserved as leading columns in the output.

Examples

brand <- brand_create(
  respondents = c("1001", "1002"),
  brands = factor(c("Nike", "Adidas"), levels = c("Nike", "Adidas"))
)
#> ✔ Created brand analysis object: 2 respondents x 2 brands = 4 panel rows.

awareness <- dplyr::tibble(
  response_id = c("1001", "1001", "1002", "1002"),
  brand = c("Nike", "Adidas", "Nike", "Adidas"),
  response = c(1, 0, 1, 1)
)

consideration <- dplyr::tibble(
  response_id = c("1001", "1001", "1002", "1002"),
  brand = c("Nike", "Adidas", "Nike", "Adidas"),
  response = c(1, NA_real_, 0, 1)
)

brand <- brand_add_funnel_stage(
  brand = brand,
  stage_data = awareness,
  stage_name = "awareness",
  verbose = FALSE
)

brand <- brand_add_funnel_stage(
  brand = brand,
  stage_data = consideration,
  stage_name = "consideration",
  parent_stage = "awareness",
  verbose = FALSE
)

brand_summarize_funnel(brand)
#> ℹ Using brand$data$weight. All weights are 1.
#> # A tibble: 2 × 4
#>   brand      n weighted_n funnel$counts$awareness $percentages$awareness
#>   <fct>  <int>      <dbl>                   <dbl>                  <dbl>
#> 1 Nike       2          2                       2                    1  
#> 2 Adidas     2          2                       1                    0.5
#> # ℹ 3 more variables: funnel$counts$consideration <dbl>,
#> #   funnel$percentages$consideration <dbl>, funnel$sequential <tibble[,2]>