cohort_count: Count the number of rows in each ggconsort cohort

Description Usage Arguments Value Functions Examples

View source: R/cohort_count.R

Description

Count the number of rows in each ggconsort cohort

Usage

1
2
3
4
5
cohort_count(.data, ...)

cohort_count_int(.data, ...)

cohort_count_adorn(.data, ..., .label_fn = NULL)

Arguments

.data

A ggconsort_cohort object

...

Cohorts to include in the output, can be quoted or unquoted cohort names, or tidyselect helpers such as [tidyselect::starts_with()].

.label_fn

An optional custom function for formatting cohort counts

Value

A tibble with cohort name, row number total, and label.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cohorts <- trial_data %>%
  cohort_start("Assessed for eligibility") %>%
    cohort_define(
      consented = .full %>% dplyr::filter(declined != 1),
      consented_chemonaive = consented %>% dplyr::filter(prior_chemo != 1)
    ) %>%
    cohort_label(
      consented = "Consented",
      consented_chemonaive = "Chemotherapy naive"
    )

cohorts %>%
  cohort_count()

cohorts %>%
  cohort_count_adorn()

cohorts %>%
  cohort_count_adorn(
    starts_with("consented"),
    .label_fn = function(cohort, label, count, ...) {
      glue::glue("{count} {label} ({cohort})")
    }
  )

tgerke/ggconsort documentation built on Dec. 23, 2021, 8:49 a.m.