Hello,everyone.
I want to create a K-M curve about bladder cancer by the metastasis of different organs.
First,I successfully create the K-M curve between two group——’metastasis‘ and ’Non-metastasis.However,when I want to investigate the relationship between the exact organ metastasis and overall survival,the R reporting'
error in as.data.frame.default(x[[i]], optional = TRUE) : **
**** cannot coerce class ‘"by"’ to a data.frame'
I have searched the internet all night,but I could not find the answers,could you help me ,thank you
seer_DM$liver.meta=ifelse(seer_DM$liver.meta=='Yes',1,0)
seer_DM$liver.meta=as.factor(seer_DM$liver.meta)
fit=survfit(Surv(Survival.months,status)~liver.meta,data=seer_DM)
summary(fit)
ggsurvplot(fit, # 创建的拟合对象
data = seer_DM, # 指定变量数据来源
conf.int = TRUE, # 显示置信区间
pval = TRUE, # 添加P值
xlab = "Survival months", # 指定x轴标签
legend.labs = c( "Non-metastasis","Metastasis"),
legend = c(0.8,0.9), # 指定图例位置
legend.title = "", # 设置图例标题
# 指定图例分组标签
break.x.by = 100) # 设置x轴刻度间距```