sankey_list_maker converts timed sankey data at the patient level to summarized counts in the nested hierarchical list format needed for the nswidgets:sankey function.

sankey_list_maker(
  id_data,
  cohort,
  stage_labels = id_data$stages,
  id_var = "patient_id",
  index_var = "index_date",
  weight = F,
  censor_vars = NULL,
  absorbing_vars = NULL,
  none = "None",
  gofl_formula = NULL,
  collapse_states = NULL,
  force = F
)

Arguments

id_data

List. One element for patient level order data, one element with states found in that data, one element with stages. Returned from sankey_id_data. Pro tip: if you want to reduce number of stages, edit the stages vector.

cohort

Cohort data.

stage_labels

How do you want the stages (time points) labelled in the widget? Default is stages in id_data.

id_var

String. Variable name of the id/grouping variable.

index_var

Date. Indicates cohort_file date or day variable name per subject when event ordering should begin.

weight

Logical. Should Sankey transitions be weighted? Default is FALSE.

censor_vars

Character vector. Variable names in cohort that indicate censoring date/day. If multiple, sankey_list_maker will use the minimum. If weight = FALSE the Sankey will use the names of the vector to label the states shown. If unnamed will group together under "Censored".

absorbing_vars

Named character vector. Variables in cohort that indicate date/day of states that members cannot transition out of. Names of the vector will be names of the states shown in the Sankey.

none

Character. How to label the "empty" state. Default is "None".

gofl_formula

Formula. How should the Sankey be filtered? Uses gofl to create groupings. Default is NULL. Overall Sankey is always created.

collapse_states

How to redefine states if combinations are anticipated. As a named list it allows users to identify how states should be grouped with unique identifiers. As a named vector it assigns a hierarchy in the order that the states appear. Default NULL.

force

Force to calculate transitions even if they exceed guidelines.

Value

Nested list with all the treatment pathways + sizes at each level.