那里!我尝试使用“plotly”包来使我的生存曲线具有交互性,因此对于可重复的示例,我使用“lung”数据集:
library(survival)
library(survminer)
library(plotly)
sf_lung <- survival::survfit(survival::Surv(time, status) ~ 1, data = lung)
p1 <- ggsurvplot(sf_lung, main = "Kaplan-Meier Curve for the NCCTG Lung Cancer Data")
plotly::ggplotly(p1)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
UseMethod("ggplotly", p) 中的错误:没有适用于 'ggplotly' 的方法应用于类“c('ggsurvplot', 'ggsurv', 'list')”的对象
那么有什么问题吗?
我的会话信息:
R 版本 4.0.2 (2020-06-22){...}
其他附加软件包:
surviviner_3.2-7 survminer_0.4.8 ggpubr_0.4.0plotly_4.9.2.1 ggplot2_3.3.2