Skip to content

Commit 2a9d75d

Browse files
committed
survival POC
1 parent fbe03a1 commit 2a9d75d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tests/testthat/_snaps/quick_surv.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
c(6L, 1L, 2L, 1L, 1L, 1L, 2L, 7L, 1L, 3L, 1L, 6L)), group = rep(c("B", "A", "B",
88
"A", "B", "A", "B", "A", "B", "A", "B"), c(9L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 7L,
99
2L, 4L)))
10+
df$time = round(df$time)
1011
df$surv = survival::Surv(df$time, df$event)
1112
fit = survival::survfit(surv ~ group, data = df)
1213
times = sort(fit$time)
1314
x = summary(fit, times = times, extend = TRUE)
1415
a = data.frame(strata = x$strata, time = x$time, n.risk = x$n.risk, n.event = x$
1516
n.event, surv = x$surv)
16-
a %>% dplyr::filter(strata == "group=B") %>% dplyr::filter(time == 140.8)
17+
a %>% dplyr::filter(strata == "group=B") %>% dplyr::filter(time == 141)
1718
Output
18-
strata time n.risk n.event surv
19-
1 group=B 140.8 15 1 0.6617647
19+
strata time n.risk n.event surv
20+
1 group=B 141 15 1 0.6640625
2021

tests/testthat/test-quick_surv.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_that("survival POC", {
1717
group = rep(c("B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B"),
1818
c(9L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 7L, 2L, 4L))
1919
)
20-
20+
df$time = round(df$time)
2121
df$surv = survival::Surv(df$time, df$event)
2222
fit = survival::survfit(surv~group, data=df)
2323
times = sort(fit$time)
@@ -26,7 +26,7 @@ test_that("survival POC", {
2626

2727
a %>%
2828
dplyr::filter(strata=="group=B") %>%
29-
dplyr::filter(time==140.8)
29+
dplyr::filter(time==141)
3030
})
3131

3232

0 commit comments

Comments
 (0)