ggprodlim: ggplot2::ggplot support for Kaplan-Meier and Aalen-Johansen...

View source: R/ggprodlim.R

ggprodlimR Documentation

ggplot2::ggplot support for Kaplan-Meier and Aalen-Johansen estimators

Description

ggplot2::ggplot support for Kaplan-Meier and Aalen-Johansen estimators

Usage

ggprodlim(x, x_at, pos_atrisk, ...)

Arguments

x

object obtained with prodlim.

x_at

Vector containg the positions for ticks on the x-axis

pos_atrisk

Vector with x positions for numbers at risk

...

passed on to as.data.table.prodlim. Can be used to specify 'cause', 'newdata', and 'times'.

Details

Important functionality like facet_grid is not yet supported

Value

A ggplot2::ggplot object

Author(s)

Thomas A. Gerds <tag@biostat.ku.dk>

See Also

plot.prodlim

Examples

library(ggplot2)
d <- SimCompRisk(117)
fit1 <- prodlim(Hist(time,event)~1,data = d)
ggprodlim(fit1,x_at = c(0,4,8,12))
g <- ggprodlim(fit1,x_at = c(0,4,8,12))+ggthemes::theme_solarized()
g+theme(plot.margin = margin(t = 0,r = 0,b = 4,l = 0,"line"))
g <- g+ggplot2::scale_fill_manual(values = grDevices::palette.colors(palette = "Okabe-Ito"))
g <- g+ggplot2::scale_color_manual(values = grDevices::palette.colors(palette = "Okabe-Ito"))
d$X1 <- factor(d$X1,levels=c("1","0"),labels=c("1","0"))
fit <- prodlim(Hist(time,event)~X1,data = d)
ggprodlim(fit,cause = 1,x_at = c(0,6,12))

tagteam/prodlim documentation built on April 13, 2025, 7:18 a.m.