Apply case_when logics (e.g. policy, censoring) to clones

apply_logics(clones, logics)

Arguments

clones

A list of data frame. Each element of the list represents each treatment arm.

logics

A nested list. Each element of outer list represents each treatment arm. Each element of inner list represents each new variable to be created by applying logics. Each element of inner list containts a character vector that represents a sequence of logics to be passed into case_when() call to determine a value of the new variable.

Value

A list of data frame that each data frame include new variables created by the provided logics.

Examples

data(lungcancer)
arms <- c("Control", "Surgery")
clones <- clone_arms(lungcancer, arms)
policies <- create_policy_A(
  arms,
  treatment = "surgery",
  time_to_treatment = "timetosurgery",
  grace_period = 182.62,
  outcome = "death",
  followup = "fup_obs",
  clone_outcome = "outcome",
  clone_followup = "fup"
)
clones_policy <- apply_logics(clones, policies)