# ggsurvfit::ggcuminc - 自定义统计数据与risktable_stats 不起作用

##### 问题描述投票：0回答：1

``````set.seed(1)
summary(time <- rnorm(200, 50, 10))
summary(event <- factor(sample(0:2, 200, replace = TRUE, prob = c(.4,.5,.1)), levels = 0:2, labels = c("censor", "event", "comp.event")))
table(female <- sample(0:1, 200, replace = TRUE), useNA = "ifany")
data <- tibble(time, event, female)

tidycmprsk::cuminc(Surv(time, event)~female, data=data) %>%
ggcuminc(outcome = "event") + add_risktable(risktable_stats = "{n.risk} ({cum.event})")
``````

match.arg(rev(risktable_stats), Choices = c("n.risk", "cum.censor", 中的错误： “arg”应该是“n.risk”、“cum.censor”、“cum.event”、“n.censor”、“n.event”之一

r ggsurvfit
##### 1个回答
0

``````library(tidyverse)
library(ggsurvfit)
packageVersion("ggsurvfit")
#> [1] '1.0.0'

set.seed(1)
summary(time <- rnorm(200, 50, 10))
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
#>   27.85   43.86   49.51   50.36   56.13   74.02
summary(event <- factor(sample(0:2, 200, replace = TRUE, prob = c(.4,.5,.1)), levels = 0:2, labels = c("censor", "event", "comp.event")))
#>     censor      event comp.event
#>         78         97         25
table(female <- sample(0:1, 200, replace = TRUE), useNA = "ifany")
#>
#>   0   1
#>  99 101
data <- tibble(time, event, female)

tidycmprsk::cuminc(Surv(time, event)~female, data=data) %>%
ggcuminc(outcome = "event") +