View source: R/create_data_matrix.R
create_data_matrix | R Documentation |
Creates a matrix suitable for create_analysis_obj()
. Creates dummy variables for factors and
allows transformations of covariates specified with a formula.
create_data_matrix(
data,
outcome,
trt_flag_col,
ext_flag_col,
covariates = NULL,
weight_var = NULL
)
data |
data.frame. Data containing all variables |
outcome |
character. The outcome variable for binary outcomes or the time and censoring variables. |
trt_flag_col |
character. The treatment indicator variable. |
ext_flag_col |
character. The external cohort indicator. |
covariates |
character or formula. The covariates for model adjustment. |
weight_var |
character. An optional weight variable. |
Invisibly returns a matrix
containing all variables to pass to create_analysis_obj()
.
Prints names of covariates columns to use with add_covariates()
.
dat <- survival::diabetic
dat$ext <- dat$trt == 0 & dat$id > 1000
data_mat <- create_data_matrix(
dat,
outcome = c("time", "status"),
trt_flag_col = "trt",
ext_flag_col = "ext",
covariates = ~ age + laser + log(risk)
)
data_mat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.