Open billudada78 opened 4 years ago
I have the same issue with a categorical variable. I get the same error regardless of whether it is a character column or factor. However, if I take out the risk table I don't get the error.
For example:
km.fit = survfit(Surv(os.months, os.status) ~ mutation.class, data=dt.survival)
ggsurvplot(km.fit, risk.table=T)
Warning message: Vectorized input to
element_text()
is not officially supported. Results may be unexpected or may change in future versions of ggplot2.
But no error with this:
km.fit = survfit(Surv(os.months, os.status) ~ mutation.class, data=dt.survival)
ggsurvplot(km.fit, risk.table=F)
I suspect it has something to do with the survminer code handling the labels for the risk table.
If it helps, I'd suggest following the ggplot2 paradigm of allowing named color vectors.
Hi, I have the same problem when leaving the label and it is worse when removing the label and/or using linetype.
Expected behavior
I expected that a variable captured as a factor should preserve the proper linking between factor level and the associated row within the risk table. I have observed that the rows within the risk table were labelled with incorrect factor levels which could cause serious issues for folks who do not spot the incorrect levels being placed against the risk rows (i.e. "Level A" could be listed alongside the row for Level B data). In the code below km_fit1 and km_fit2 should result in similar plots with perhaps a different sort order on the group:
Actual behavior
Looking at the plots below, you can see that the figures are fine and consistent, but that the labels in risk tables have been "randomly" sorted in the case where the factor variable, initial_group, was used instead of its character equivelent, initial_group_c. The group "UM", for example, has only one observation and this group is wrongly listed alongside "zorgmedewerkers" in the first plot. Similarly, the other groups are wrongly placed in some random order.
Using factor version of the variable (km_fit1):
Using character version of the variable (km_fit2):
session_info()