-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stat_km and geom_km for Kaplan-Meier Survival curves #1080
Comments
It looks like library(survMisc)
data(kidney, package="KMsurv")
s1 <- survfit(Surv(time=time, event=delta) ~ type, data=kidney)
autoplot(s1)
autoplot(s1, CI=TRUE, pval=TRUE, plotTable=TRUE, divideTime=5,
legendLabs=c("surgical", "percutaneous"),
title="Time to infection following catheter placement \n
by type of catheter, for dialysis patients")
s1 <- survfit(Surv(time=time, event=delta) ~ 1, data=kidney)
autoplot(s1)
data(rectum.dat, package="km.ci")
s1 <- survfit(Surv(time, status) ~ 1, data=rectum.dat)
### change confidence intervals to log Equal-Precision confidence bands
km.ci::km.ci(s1, method="logep")
autoplot(s1, bands=TRUE) |
@MarcinKosinski Thanks for pointing that out, I was not aware of that function. While this autoplot does use ggplot2 to create a survival plot, I don't agree that it is done in the "ggplot way". I.e., there is no support for faceting, scale transformations, or even themes. Furthermore, it ignores the key concepts of the grammar of graphics, such as aesthetic mappings, layers, statistical transformations, and so on. |
I'd rather it go in a separate package - have you considered adding the data related parts to broom? |
I'm very much interested in these functions, have been looking for survival functionality for ggplot forever. Found some solutions but none have been very satisfactory. How can I access these functions? |
@fpbarthel They're available at my repo here, still under development and not on CRAN yet. |
Thanks |
Have a look at 'survminer' package :) available at CrAN and github Marcin Kosinski Dnia 18.02.2016 o godz. 18:18 fpbarthel notifications@github.com napisał(a):
|
@MarcinKosinski great package. Much more flexible than autoplot. |
People occasionally ask about plotting survival curves with ggplot2. While it is possible, see here for some examples, it's not done in the "ggplot way" and people often revert to the base plot because it's so much easier (but not nearly as powerful).
I've worked a bit on adding a stat and geom for computing and plotting survival curves here. I view it as along the same lines as
stat_ecdf
but for censored data. Before submitting a pull request I wanted to ask if this would be suitable for inclusion in ggplot2, or if it would be better as a standalone package?Here's an example code and plot:
The text was updated successfully, but these errors were encountered: