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`)
|
[1] 0.9741226 0.9239601 0.8689171
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Warning message:
`as_data_frame()` is deprecated, use `as_tibble()` (but mind the new semantics).
This warning is displayed once per session.
# A tibble: 9 x 3
surv_prob_time group surv_prob
<dbl> <chr> <dbl>
1 100 Obs 0.973
2 200 Obs 0.917
3 300 Obs 0.848
4 100 Lev 0.971
5 200 Lev 0.911
6 300 Lev 0.854
7 100 Lev+5FU 0.979
8 200 Lev+5FU 0.944
9 300 Lev+5FU 0.906
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.