Is there a way to add the greater than symbol ">" in ggsurvplot? in the figure legend?
Have you got an example? It just uses the ggplot2
syntax.
Sure, here it is:
structure(list(X = 1:26, OS = c(59, 115, 156, 421, 431, 448,
464, 475, 477, 563, 638, 744, 769, 770, 803, 855, 1040, 1106,
1129, 1206, 1227, 268, 329, 353, 365, 377), OS_event = c(1, 1,
1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 0), age = c("> 50 years", "> 50 years", "> 50 years", "> 50 years",
"> 50 years", "> 50 years", "> 50 years", "> 50 years", "> 50 years",
"> 50 years", "> 50 years", "> 50 years", "> 50 years", "< 50 years",
"< 50 years", "< 50 years", "< 50 years", "< 50 years", "< 50 years",
"< 50 years", "< 50 years", "< 50 years", "< 50 years", "< 50 years",
"< 50 years", "< 50 years"), resid.ds = c(2L, 2L, 2L, 2L, 2L,
1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L,
2L, 2L, 1L, 2L, 1L), rx = c(1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L,
2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L,
2L), ecog.ps = c(1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L,
1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L)), row.names = c(NA,
-26L), class = "data.frame")
And my code:
###### Load data and packages
pacman::p_load(pacman, party, rio, tidyverse)
library(survival) # Load survival curve package
library(survminer)
library(ggtext)
ovarian <- read.csv("~/Desktop/ovarian.csv", stringsAsFactors = FALSE)
ovarian$OS = as.numeric(ovarian$OS)
ovarian$OS_event = as.numeric(ovarian$OS_event)
# Run KM plot:
ggsurvplot(survfit(Surv(OS, OS_event) ~ ovarian$age,
data = ovarian),
risk.table = TRUE,
pval = TRUE,
pval.coord = c(72,0.8),
legend.labs = c("< 55 years", "> 55 years"),
title = " OS by binarised median age",
legend = "right",
legend.title = "Binarised
median age",
break.x.by=24,
palette = c("red", "blue"),
xlab="Time (Months)",
xlim=c(0,96))
The error message is:
Error: gridtext has encountered a tag that isn't supported yet:
Only a very limited number of tags are currently supported.
Which relates to this: Error message: unsupported tags? · Issue #48 · wilkelab/ggtext · GitHub
The >
only partly works though.
Thanks, I also tried your approach which seems to fix the problem in the risk table, but the legend inadvertently displays the ">" text instead of the ">" symbol. Any thoughts on how to go about resolving this?
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.