rk.survival upgrades the survival analysis capabilities of RKWard by integrating the powerful survival and survminer packages. It allows users to perform rigorous survival analysis and generate publication-quality, ggplot2-based visualizations (Kaplan-Meier curves, Forest plots, and Diagnostic plots) via a simple GUI.
This package installs a new submenu in RKWard: Analysis > Survival Analysis (survminer).
Kaplan-Meier Analysis:
survfit) and plot them instantly (ggsurvplot).Cox Proportional Hazards:
coxph).ggforest plot to visualize Hazard Ratios.Cox Diagnostics:
cox.zph).install.packages(c("survival", "survminer", "ggplot2"))
devtools (for installation from source).local({
## Preparar
require(devtools)
## Computar
install_github(
repo="AlfCano/rk.survival"
)
## Imprimir el resultado
rk.header ("Resultados de Instalar desde git")
})
To test these plugins, we will use the standard lung cancer dataset included in R.
Run this code in the RKWard console to load the data and label the factors (so the plots look nice):
library(survival)
data(lung)
# Convert 'sex' from 1/2 to Male/Female labels
lung$sex <- factor(lung$sex, levels = c(1, 2), labels = c("Male", "Female"))
Compare survival rates between Men and Women.
time.status.sex.Analyze the effect of Age, Sex, and Performance Score on survival.
time.status.age, sex, and ph.ecog (ECOG performance score).cox_model.sexFemale is to the left of the line (HR < 1), indicating a protective effect.Check if the "Proportional Hazards" assumption holds true for our model.
cox_model created in the previous step.Alfonso Cano Robles
Assisted by Gemini, a large language model from Google.