Skip to content

Commit 7110d14

Browse files
committed
add table.censor option to svy also
1 parent 5768065 commit 7110d14

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

R/svyjskm.R

+12-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#' @param design Data design for reactive design data , Default: NULL
2525
#' @param subs = NULL,
2626
#' @param table logical: Create a table graphic below the K-M plot, indicating at-risk numbers?
27+
#' @param table.censor logical: Add numbers of censored in table graphic
2728
#' @param label.nrisk Numbers at risk label. Default = "Numbers at risk"
2829
#' @param size.label.nrisk Font size of label.nrisk. Default = 10
2930
#' @param cut.landmark cut-off for landmark analysis, Default = NULL
@@ -80,6 +81,7 @@ svyjskm <- function(sfit,
8081
design = NULL,
8182
subs = NULL,
8283
table = F,
84+
table.censor = F,
8385
label.nrisk = "Numbers at risk",
8486
size.label.nrisk = 10,
8587
cut.landmark = NULL,
@@ -656,7 +658,16 @@ svyjskm <- function(sfit,
656658
time = summary(sfit2, times = times, extend = TRUE)$time[subs3],
657659
n.risk = summary(sfit2, times = times, extend = TRUE)$n.risk[subs3]
658660
)
659-
661+
if(table.censor){
662+
risk.data <- data.frame(
663+
strata = Factor,
664+
time = summary(sfit2, times = times, extend = TRUE)$time[subs3],
665+
n.risk = summary(sfit2, times = times, extend = TRUE)$n.risk[subs3],
666+
n.censor = summary(sfit2, times = times, extend = TRUE)$n.censor[subs3]
667+
)
668+
risk.data$n.risk <- paste0(risk.data$n.risk, " (", risk.data$n.censor, ")")
669+
risk.data$n.censor <- NULL
670+
}
660671

661672
risk.data$strata <- factor(risk.data$strata, levels = rev(levels(risk.data$strata)))
662673

man/svyjskm.Rd

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)