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)
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 throws a error. I tried googling to find a solution but was unsuccessful. Any help would be appreciated