我有一个数据框dt
,如下所示:
dt <- structure(list(Patient = structure(1:5, .Label = c("Sample-3L-AA1B",
"Sample-4N-A93T", "Sample-4T-AA8H", "Sample-5M-AAT4", "Sample-5M-AAT6"), class = "factor"), years = c(1.3013698630137, 0.4, 1.05479452054795,
0.134246575342466, 0.794520547945205), patient_vital_status = c(0L,
0L, 0L, 1L, 1L), `5S_rRNA` = c(0.772491219057, 1.12342309804,
0.283762608812, 0.882492010705, 0.805980084005), `5_8S_rRNA` = c(0,
0, 0, 0, 0), `7SK` = c(0.075067668297, 0, 0, 0.138592705037,
0.210961230042), A1BG = c(0.0282019073358, 0.169523031145, 0.00835845927105,
0.00515484599363, 0.0470792160901)), row.names = c(NA, 5L), class = "data.frame")
我正在尝试将以下代码应用于必填列,并将每个输出附加到列表中。
library(survminer)
library(survival)
# vector with the variables to run through
genes <- colnames(dt[4:7])
datalist = data.frame()
for(i in 1:length(genes)){
surv_rnaseq.cut <- surv_cutpoint(
dt,
time = "years",
event = "patient_vital_status",
variables = c(genes[i]))
surv_rnaseq.cat <- surv_categorize(surv_rnaseq.cut)
fit <- survfit(as.formula(paste0("Surv(years, patient_vital_status) ~", genes[i])),
data = surv_rnaseq.cat)
fr <- data.frame(surv_pvalue(fit, surv_rnaseq.cat))
datalist <- rbind(datalist, fr)
}
我遇到以下错误:
Error in parse(text = x, keep.source = FALSE) :
<text>:1:37: unexpected symbol
1: Surv(years, patient_vital_status) ~5S_rRNA
^
我认为这可能是由于名称中的_
符号引起的。我什至删除了它并检查了一下,但是没有用。