Description Usage Arguments Value Examples
get_surv_prob
retrieves the survival probability at a specific time
from a survival curve object from the survival::survfit function. The
survival curve object can only have one group.
1 | get_surv_prob(fit, times)
|
fit |
survival::survfit object. |
times |
Vector of times to lookup survival probabilities. |
Vector of survival probabilities based on the input times.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library("survival")
# Get Survival Probabilities Based on Whole Cohort
fit <- survfit(Surv(time, status) ~ 1, data = colon)
times <- c(100, 200, 300)
get_surv_prob(fit, times)
# Get Survival Probabilities for Each rx Group
library("purrr")
library("dplyr")
library("tidyr")
surv.prob.res <-
colon %>%
split(.$rx) %>%
map(~ survfit(Surv(time, status) ~ 1, data = .)) %>%
map(get_surv_prob, times)
surv.prob.res.df <- as_data_frame(surv.prob.res)
colnames(surv.prob.res.df) <- names(surv.prob.res)
surv.prob.res.df <-
surv.prob.res.df %>%
mutate(surv_prob_time = times)
gather(surv.prob.res.df, "group", "surv_prob", Obs:`Lev+5FU`)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.