Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205793

ggsurvplot:Error in parse(text = paste0("list(", paste(varnames, collapse = ","), : :1:25: unexpected symbol on

$
0
0

I am trying to plot a KM curve using ggsurvplot. R throws an "unexpected symbol" , exception when I use a string something like this as a variable "RP11-181G12.2" (please see the code). There seems no issue when plotting using plot function.

rnaID <-"`RP11-181G12.2`"
days <- mergeData$Days
event <- as.integer(factor(mergeData$Vital_Status, levels = c("Alive", "Dead")))
surv <- sprintf("Surv(days,event)~as.numeric(%s >median(%s))",rnaID,rnaID)
fit_train <-survfit(formula=as.formula(surv),data= mergeData)
fit_train <- survfit(obj~ rnaID,data=mergeData)
ggsurvplot(fit_train,data=mergeData)

When I give the string directly into surv string for the formula the ggsurvplot has no issues in ploting the curve but when I give it as variable it throw the error. I tried googling to find a solution but was unsuccessful. Any help would be appreciated


Viewing all articles
Browse latest Browse all 205793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>