Learn R Programming

DynNom (version 4.0)

DNbuilder.coxph: Shiny code for Dynamic Nomograms

Description

DNbuilder.coxph provides required scripts to deploy an lm model object as a dynamic nomogram on a server on the web such as the http://shinyapps.io.

Usage

DNbuilder.coxph(model, data, clevel = 0.95, covariate = c("slider", "numeric"), ptype = c("st", "1-st"))

Arguments

model
a coxph model object
data
dataframe containing the accompanying data
clevel
confidence level required
covariate
The option to choose the type of covariate(s) input control widget for numeric values. If "slider" (the default) is chosen a shiny application with slider control widgets are used while if "numeric" is chosen numeric values input controls will be displayed.
ptype
If "st" (the default) is chosen, a plot of the estimated survivor function, S(t), is displayed. If "1-st" is chosen a plot of 1- S(t) is displayed.

Value

A new folder in the current working directory called DynNomapp which contains all the required scripts to deploy this dynamic nomogram on a server on the web such as the http://shinyapps.io. This folder includes ui.R, server.R and global.R script files needed to build the application and dataset.rds which is the accompanying dataset and a user guide text file called README.txt which explains how to deploy the app using all these objects.

See Also

coxph, DynNom, DynNom.coxph

Examples

Run this code
## Not run: 
# data.kidney <- kidney
# # always make sure that the categorical variables are in a factor class
# data.kidney$sex <- as.factor(data.kidney$sex)
# levels(data.kidney$sex) <- c("male", "female")
# 
# model1 <- coxph(Surv(time, status) ~ age + sex + disease, data.kidney)
# DNbuilder(model1, data.kidney)
# DNbuilder(model1, data.kidney, ptype = "1-st")
# 
# # a cox model including a strata term
# data(lung)
# model2 <- coxph(Surv(time, status) ~ age + strata(sex) + ph.ecog , data = lung)
# DNbuilder(model2, lung)
# ## End(Not run)

if (interactive()) {
data.ovary <- ovarian
data.ovary$resid.ds <- as.factor(data.ovary$resid.ds)
levels(data.ovary$resid.ds) <- c("no", "yes")
data.ovary$rx <- as.factor(data.ovary$rx)
data.ovary$ecog.ps <- as.factor(data.ovary$ecog.ps)

model3 <- coxph(Surv(futime, fustat) ~ age + resid.ds * rx + ecog.ps, data = data.ovary)
DNbuilder.coxph(model3, data.ovary)
}

Run the code above in your browser using DataLab