Error with add_censor_mark() in ggsurvfit package when used with weighted survival data

16 Views Asked by At

Wanted to add censor mark to the weighted KM curves but encountered error - any work around or solutions?

fit <- survfit2(Surv(survival_time, event) ~ tx, data = ttd, weights = wt01)

fit %>%
  ggsurvfit()+
  add_risktable(
  risktable_stats =
    c("{round(n.risk,1)}", "{round(cum.event,1)}", "{round(cum.censor,1)}"),
  stats_label = c("At Risk", "Cum. Events", "Cum. Censor"),
  times=seq(0,36,3))+
   add_quantile(y_value = 0.5, linetype = "dotted", color = "grey30", linewidth = 0.8) +
  add_censor_mark()

Error received was

Error in ggplot2::geom_point() at rlang/R/eval.R:195:3: ! Problem while computing layer data. ℹ Error occurred in the 4th layer. Caused by error in tidyr::uncount(): ! Can't convert from weights to due to loss of precision.

Thanks! Sophia

Tried with the above code but encountered error.

0

There are 0 best solutions below