Adding median value and superscript characters in a survival curve in R

Is there a way to display the median value (and not the median line) in a survival plot? I would like it to appear similar to how the p-value appears in my code below.

Also, is there a way to assign superscript numbers to categories mentioned in survival plot? For instance using the example of your plot above, would it be possible to mark the "years" in the risk table and the legend as a superscript character? I have tried using the "^" symbol in the legend.labs part of the code but it only implements the change in the risk table, not the legend.

Here is my sample dataset and code for this problem:

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")

Load data and packages pacman::p_load(pacman, party, rio, tidyverse) library(survival)

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)

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))

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.