0

I changed the name of my variable so that the actual name of the variable is displayed in the graph instead of a name separated by an underscore.

pts_raw_reg<-pts_raw_reg%>%rename(
  "Surgery type"=baria_t
)

fit<-survfit(Surv(duree_suivi,Cancer)~`Surgery type`, data=pts_raw_reg)

But the function survfit does not take into account my variable name inside the backticks.

I have this error message:

Error in `[.data.frame`(mf, ll) : colonnes non définies sélectionnées



ggsurv<-ggsurvplot(fit, conf.int = TRUE, 
           palette = c("#FF9E29", "#86AA00"),
           risk.table = TRUE, risk.table.col = "strata",
           fun = "cumhaz", yli=c(0,0.05)
)
Seydou GORO
  • 1,147
  • 7
  • 13
  • 3
    Are you doing this rename just so you have nice axis labels? Because it would be better to keep the computer-friendly column names and then change the settings for human friendly labels when you draw the plot. – MrFlick Nov 14 '22 at 14:18
  • Yes, it's just to have nice graphics. I'm interested in any script that will allow me to change the label without necessarily changing the variable name – Seydou GORO Nov 14 '22 at 14:23
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. I would guess that you could just add `+labs(x="", y="")` to set the labels to whatever you want like you can do with most ggplot objects. But I would have to test to make sure. – MrFlick Nov 14 '22 at 14:43

0 Answers0