knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The goal of ezcox is to operate a batch of univariate or multivariate Cox models and return tidy result.
You can install the released version of ezcox from CRAN with:
install.packages("ezcox")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("ShixiangWang/ezcox")
Visualization feature of ezcox needs the recent version of forestmodel, please run the following commands:
remotes::install_github("ShixiangWang/forestmodel")
This is a basic example which shows you how to get result from a batch of cox models.
library(survival) library(ezcox) data(lung) head(lung) # Build unvariable models ezcox(lung, covariates = c("age", "sex", "ph.ecog")) # Build multi-variable models # Control variable 'age' ezcox(lung, covariates = c("sex", "ph.ecog"), controls = "age")
For parallel computation, users can use ezcox_parallel()
. This function has same arguments as ezcox()
.
For variables < 200, this function is not recommended.
ezcox_parallel(lung, covariates = c("sex", "ph.ecog"), controls = "age")
Sometimes, we may need to filter result from multi-variable models.
lung$ph.ecog = factor(lung$ph.ecog) zz = ezcox(lung, covariates = "sex", controls = "ph.ecog") zz # At default, it will drop all control variables filter_ezcox(zz) # You can specify levels to filter out filter_ezcox(zz, c("0", "2")) filter_ezcox(zz, c("0", "2"), type = "contrast") filter_ezcox(zz, c("0", "2"), type = "ref") # More see ?filter_ezcox
Get raw models may help users understand the detail and do further visualization.
zz = ezcox(lung, covariates = c("sex", "ph.ecog"), controls = "age", return_models=TRUE) mds = get_models(zz) str(mds, max.level = 1)
show_models(mds) # Set model names show_models(mds, model_names = paste0("Model ", 1:2)) # Merge all models and drop control variables show_models(mds, merge_models = TRUE, drop_controls = TRUE)
More see ?show_models
.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.