knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The jsurvival
package provides functions to help researchers carry out
survival analyses and produce publication ready tables and plots.
It supports several workflows ranging from simple survival summaries to
multi‑arm comparisons.
This vignette gives a brief tour of the main functions with example code
using the built in histopathology
data set.
The package ships with a small demonstration data frame histopathology
.
Some of the available variables are:
Sex
Race
Group
Grade
SurgeryDate
LastFollowUpDate
Death
DeathTime
# load the included data library(jsurvival) data(histopathology) head(histopathology)
The core function of the package is survival()
, which calculates
Kaplan–Meier estimates and related summaries. The minimal usage requires
a data frame with the follow up time and an event indicator.
res <- survival( data = histopathology, elapsedtime = DeathTime, outcome = Death, outcomeLevel = "1", explanatory = Group, ci95 = TRUE, risktable = TRUE ) # results object contains tables and plots res$plot
For analyses with a continuous explanatory variable the
survivalcont()
function provides an interface that can optionally find a
cut‑point for dichotomisation.
res <- survivalcont( data = histopathology, elapsedtime = DeathTime, outcome = Death, outcomeLevel = "1", contexpl = `Anti-X-intensity`, findcut = TRUE )
oddsratio()
computes odds ratios for binary outcomes with optional
adjustment for explanatory factors.
res <- oddsratio( data = histopathology, outcome = Mortality5yr, explanatory = Group )
In situations where only a single treatment group is available,
singlearm()
summarises survival and provides median estimates.
res <- singlearm( data = histopathology, elapsedtime = DeathTime, outcome = Death, outcomeLevel = "1" )
The multisurvival()
function extends the framework to multiple
explanatory variables for a comprehensive analysis across several groups.
res <- multisurvival( data = histopathology, elapsedtime = DeathTime, outcome = Death, outcomeLevel = "1", explanatory = c(Group, Grade, Race) )
The documentation of each function contains many more options.
See help(package = "jsurvival")
for details and consult the
package website for worked examples.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.