You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an issue with the ggsurvplot function from the survminer package in R. When attempting to plot survival curves using ggsurvplot with the newdata argument, the function incorrectly interprets the number of observations as the number of levels, resulting in an error. Without the newdata argument, the function does not recognize the levels of the factor variable correctly, leading to another error.
Steps to Reproduce:
Data Preparation:
Clean and prepare the dataset ensuring the factor variable is correctly defined.
This results in the error:
Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, :
The length of legend.labs should be 236
(236 is the number of cases I have.)
Without newdata Argument:
The function fails to recognize the levels of the factor variable correctly and returns:
Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, :
The length of legend.labs should be 1
Expected Behavior:
The function should correctly interpret the levels of the factor variable and plot the survival curves without error.
Environment:
R version: R 4.2.3 GUI 1.79 High Sierra build (8198)
survminer version: 0.4.9.999
survival package version: 3.7.0
Operating system: macOS 10.15.7
Any help or guidance on how to resolve this issue would be greatly appreciated.
Thank you so much!!!!
I am experiencing an issue with the
ggsurvplot
function from thesurvminer
package in R. When attempting to plot survival curves usingggsurvplot
with thenewdata
argument, the function incorrectly interprets the number of observations as the number of levels, resulting in an error. Without thenewdata
argument, the function does not recognize the levels of the factor variable correctly, leading to another error.Steps to Reproduce:
Data Preparation:
Clean and prepare the dataset ensuring the factor variable is correctly defined.
Cox Model Fitting:
Fit a Cox proportional hazards model.
Create Survival Curves:
Create survival curves using the survfit function.
surv_fit <- survfit(cox_model_single_111758446)
Plot Survival Curves:
Attempt to plot the survival curves using ggsurvplot.
Observed Behavior:
With newdata Argument:
This results in the error:
Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, :
The length of legend.labs should be 236
(236 is the number of cases I have.)
Without newdata Argument:
The function fails to recognize the levels of the factor variable correctly and returns:
Error in ggsurvplot_df(d, fun = fun, color = color, palette = palette, :
The length of legend.labs should be 1
Expected Behavior:
The function should correctly interpret the levels of the factor variable and plot the survival curves without error.
Environment:
Any help or guidance on how to resolve this issue would be greatly appreciated.
Thank you so much!!!!
Reproducible example:
The text was updated successfully, but these errors were encountered: