Questions tagged [survminer]

Questions related to survminer package

An R package that draws survival curves using 'ggplot2'. See more details at survminer documentation.

95 questions
7
votes
2 answers

Plotting a Cox PH model using ggforest in RStudio when a factor is stratified?

I am trying to find a way to make a forest plot of hazard ratios from a Cox-PH model when one of the model variables needs to be stratified. For a non-stratified model, the ggforest() function is excellent. Running some example…
Charlie B
  • 85
  • 1
  • 5
6
votes
1 answer

Change x-axis labels for ggsurvplot

library(survival) library(survminer) I am using the survminer package to plot unadjusted Kaplan Meier plots. I am calculating mortality comparing different exposures and I have a very specific problem: Is there a way to change the x axis labels of…
Pontus Hedberg
  • 301
  • 1
  • 2
  • 9
5
votes
1 answer

ggsave Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "c('ggsurvplot', 'ggsurv', 'list')"

So I made a ggplot using a survifit curve. Wolcurves <- survfit(Surv(Days, Survival) ~ Wol, data = DCV_noPBS) IFB_plot <- ggsurvplot(Wolcurves, data = DCV_noPBS, line = c(2, 1), pval = "p-value = 0", …
AngeLeek
  • 51
  • 2
5
votes
3 answers

Remove variable name from legend in ggsurvplot

Is there a concise way to remove the variable name in the legend of plots created by ggsurvplot? Example: library(survival) library(survminer) set.seed(123) df=data.frame(gender=c(rep("male", 10), rep("female", 10)), value=c(rnorm(10,mean = 2),…
otwtm
  • 1,779
  • 1
  • 16
  • 27
4
votes
1 answer

Change Kaplan-Meier plot y-axis to failure probability instead of survival probability using survminer (ggsurvplot)?

I am creating a Kaplan-Meier plot that shows the relationship between family history of mental illness and mental illness onset using ggsurvplot from the survminer package. This is the code I have used: km_fhr <- ggsurvplot(fit =…
dam4l10
  • 349
  • 4
  • 11
3
votes
1 answer

I want to annotate (add letters eg A and B) to the resulting 2 Kaplan Meier curves plots using splots and survminer in R

I need to add letters eg A and B to the resulting 2 Kaplan Meier curves plots code library(survminer) # Fit survival curves require("survival") fit<- survfit(Surv(time, status) ~ sex, data = lung) # List of ggsurvplots require("survminer") splots <-…
Mohamed Rahouma
  • 1,084
  • 9
  • 20
3
votes
1 answer

ggplot2/ggsurvplot: Vectorized input to `element_text()` is not officially supported

I'm trying to plot survival curves for a corresponding analysis using survminer & survival packages. Setting risk.table = TRUE in the ggsurvplot command results in a warning saying 'Vectorized input to element_text() is not officially supported.…
GRowInG
  • 357
  • 3
  • 14
3
votes
2 answers

Is there a way to flip y-axes ticks on ggsurvplot without changing the results?

I am using survival analysis to show the proportion of individuals/duration to reach a developmental milestone, and I would like to flip the y-axis ticks so it has 0 at the top and 1.00 at the bottom. I tried using scale_y_reverse, but this flipped…
bibigeans
  • 115
  • 5
3
votes
1 answer

ggadjustedcurves survminer Error in if (xi > xj) 1L else -1L

I'm trying to use survminer to create an adjusted survival curve with ggadjustedcurves(). My code is as follows: adjustedcurve <- coxph(Surv(time_DeathTxCensor, deadORtx==1) ~ strata(natADI_quart) + sex + FVCpctPre + DLCOpctPre + smokeHx + age_dx,…
gcgoobie
  • 53
  • 2
3
votes
0 answers

Unable to plot p values when using facet.by from ggsurvplot. Error message: "variable lengths differ"

I have a problem that I don't know how to solve. And it seems to be related to my data set (or is it?). Indeed, I am actually able to plot different p values when using facet.by when I use your example from issue#205 via the "colon" data set.…
3
votes
1 answer

Specifying custom time points for survival plot

I'm working on creating a survival/cumulative event plot using the ggsurvplot function from the survminer package. I want to specify custom time points for my plot, but I cannot figure out how to do so. The xlim and break.x.by parameters kind of…
user122514
  • 397
  • 5
  • 13
2
votes
1 answer

How do I change the size of the legend text in the risk table using R package survminer?

I need help. I did lots of online research trying to find a solution to change the size of the legend text in the risk table using R package survminer. Everything else in the KM plot is adjustable but I cannot change font size for the "Male"…
Jason
  • 21
  • 1
2
votes
1 answer

How to use ggrepel with a survival plot (ggsurvplot)?

I would like to add the label of each survival curve at the end of the lines. I am using ggsurvplot from the Survminer package (which is based on ggplot2). I don't know how to do it with ggrepel. I didn't find any example with survival…
Flora Grappelli
  • 659
  • 9
  • 26
2
votes
1 answer

Change xlim to cartesion coordinates in ggsurvplot

I want to create a KM curve with 95%-CI with the x-axis zoomed in to show values between 0-60 months. This all works fine with ggsurvplot untill I use xlim. ggsurvplot(fitLC, data = KMSCC, risk.table = TRUE, conf.int=TRUE, pval…
Tdebeus
  • 1,519
  • 5
  • 21
  • 43
2
votes
1 answer

How to drop the facet argument using panel.labs with survminer::ggsurvplot_facet?

I use the following code to facet plots in a survival analysis: surv_plot <- ggsurvplot_facet(fit, matrix_surv, facet.by = c("Place","Year"), panel.labs =list(Lieu_libelle = c("Austria","Belgium","Denmark","Finland","Italy"), …
Mata
  • 538
  • 3
  • 17
1
2 3 4 5 6 7