| track_split | R Documentation |
Adds one branching level to the flow tree. The cohort is divided by the
distinct values of by. Chain multiple track_split() calls to create
nested branches (e.g. exposure then mediator). Passes the data through
unchanged, so it fits in a %>% pipeline.
track_split(sdf, by, label = NULL, value_labels = NULL, max_levels = 3L)
sdf |
A Spark DataFrame or local data frame. |
by |
Character. Column name to split by. Its distinct values become the branches. NA values are grouped as "(NA)". |
label |
Optional character. A human-readable name for this split
level (e.g. "Exposure: drought"). Defaults to |
value_labels |
Optional named character vector mapping raw values to
readable labels, e.g. |
max_levels |
Integer. Safety cap on nesting depth. Default 3. |
sdf unchanged (for piping).
cb_init(id_col = "id_indiv")
df <- data.frame(
id_indiv = sprintf("ID%03d", 1:100),
exposto_seca = sample(c(0L, 1L), 100, replace = TRUE),
migrou = sample(c(0L, 1L), 100, replace = TRUE),
obito_dcv = sample(c(0L, 1L), 100, replace = TRUE)
)
df <- track_split(df, by = "exposto_seca", label = "Exposure: drought",
value_labels = c("0" = "No drought", "1" = "Drought"))
df <- track_split(df, by = "migrou", label = "Mediator: migration",
value_labels = c("0" = "Did not migrate", "1" = "Migrated"))
track_outcomes(df, vars = "obito_dcv", labels = list(obito_dcv = "CVD death"))
flow_table()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.