问题遇到的现象和发生背景
绘制预后列线图,进行多因素cox模型构建时,出现下标越界报错:Error in [.default
(y, , 3) : subscript out of bounds
问题相关代码,请勿粘贴截图
mycox<-read.csv("G:/Rprojs/sample.csv")
setwd("G:/Rprojs")
library(rms)
dd=datadist(mycox)
options(datadist="dd")
mycox$event <- as.factor(mycox$event)
mycox$Gender <- as.factor(mycox$Gender)
mycox$Stage <- factor(mycox$Stage)
mycox$G <- as.factor(mycox$G)
mycox$R <- as.factor(mycox$R)
mycox$Radiation <- as.factor(mycox$Radiation)
#预测模型列线图
library(survival)
library(pec)
library(dplyr)
library(magrittr)
nomo.cox <- cph(formula=Surv(time, event) ~ FAM3D + Age + Gender + Stage + G + R + Radiation, data=mycox, x=TRUE, y=TRUE, surv=TRUE, na.action=na.delete)
运行结果及报错内容
Error in [.default
(y, , 3) : subscript out of bounds
我的解答思路和尝试过的方法
y = matrix(data = sample.int(3000, 3000), nrow = 3000, ncol = 3000),没有效果
我想要达到的结果
想让代码不报错,成功构建cox模型,后续再形成列线图,感谢!