ggkm | R Documentation |
Produce nicely annotated KM plots using ggplot style.
ggkm(
sfit,
sfit2 = NULL,
table = TRUE,
returns = TRUE,
marks = TRUE,
CI = TRUE,
line.pattern = NULL,
shading.colors = NULL,
main = "Kaplan-Meier Plot",
xlabs = "Time",
ylabs = "Survival Probability",
xlims = NULL,
ylims = NULL,
ystratalabs = NULL,
cox.ref.grp = NULL,
timeby = 5,
test = c("Log Rank", "Tarone-Ware"),
pval = TRUE,
bold_pval = FALSE,
sig.level = 0.05,
HR = TRUE,
hide_hr_labels = FALSE,
use.firth = 1,
hide.border = FALSE,
expand.scale = TRUE,
legend = FALSE,
legend.xy = NULL,
legend.direction = "horizontal",
line.y.increment = 0.05,
size.plot = 11,
size.summary = 3,
size.table = 3.5,
size.table.labels = 11,
digits = 3,
...
)
sfit |
an object of class |
sfit2 |
an (optional) second object of class |
table |
logical; if |
returns |
logical; if |
marks |
logical; if |
CI |
logical; if |
line.pattern |
linetype for survival curves |
shading.colors |
vector of colours for each survival curve |
main |
plot title |
xlabs |
horizontal axis label |
ylabs |
vertical axis label |
xlims |
horizontal limits for plot |
ylims |
vertical limits for plot |
ystratalabs |
labels for the strata being compared in |
cox.ref.grp |
indicates reference group for the variable of interest in the cox model. this parameter will be ignored if not applicable, e.g. for continuous variable |
timeby |
length of time between consecutive time points spanning the entire range of follow-up. Defaults to 5. |
test |
type of test. Either "Log Rank" (default) or "Tarone-Ware". |
pval |
logical; if |
bold_pval |
logical; if |
sig.level |
significance level; default 0.05 |
HR |
logical; if |
hide_hr_labels |
logical; if |
use.firth |
Firth's method for Cox regression is used if the percentage
of censored cases exceeds |
hide.border |
logical; if |
expand.scale |
logical; if |
legend |
logical; if |
legend.xy |
named vector specifying the x/y position of the legend |
legend.direction |
layout of items in legends ("horizontal" (default) or "vertical") |
line.y.increment |
how much y should be incremented for each line |
size.plot |
text size of main plot |
size.summary |
text size of numerical summaries |
size.table |
text size of risk table |
size.table.labels |
text size of risk table axis labels |
digits |
number of digits to round: p-values digits=number of significant digits, HR digits=number of digits after decimal point NOT significant digits |
... |
additional arguments to other methods |
A kaplan-meier plot with optional annotations for hazard ratios, log rank test p-values, and risk table counts for each stratum.
Samuel Leung, Derek Chiu
library(survival)
sfit <- survfit(Surv(time, status) ~ sex, lung)
ggkm(sfit, timeby = 200, main = "Survival curves by sex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.