问题描述
有! 我尝试使用软件包“ plotly”使我的生存曲线互动,因此对于可重现的示例,我使用“肺”数据集:
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)
那我得到的错误:
UseMethod(“ ggplotly”,p)中的错误: 没有适用于“ ggplotly”的适用方法应用于类“ c('ggsurvplot','ggsurv','list')”的对象
那怎么了?
我的会话信息:
R版本4.0.2(2020-06-22){...}
其他附件包:
Survivin_3.2-7 survminer_0.4.8 ggpubr_0.4.0 plotly_4.9.2.1 ggplot2_3.3.2
解决方法
ggsurvplot创建了一个列表对象。仅使用第一项(“情节”) 至少对我有用。
<TextField
id="standard-basic"
label="label"
defaultValue={valueList[index]}
onChange={(event) => {
let newValueList = [...valueList]; // <-- pay attention to usage of spread syntax
newValueList[index] = event.target.value;
setValueList(newValueList);
console.log(valueList);
}}
value={valueList[index]} // <-- we can transform this to a controlled component
/>