pharmaverse / ggsurvfit

http://www.danieldsjoberg.com/ggsurvfit/
Other
67 stars 19 forks source link

Bug Report: ggplot2 version 3.5.0 now throws warnings in add_risktable() - "Did you mean to use annotate()?" #191

Open dereksonderegger opened 3 months ago

dereksonderegger commented 3 months ago

It seems in the most recent update to ggplot2, there is now a warning thrown if the number of aesthetic attributes doesn't match the number of data rows. This warning now gets generated when add_risktable() is used. The error is most easily confirmed in the current documentation page:

https://www.danieldsjoberg.com/ggsurvfit/reference/add_risktable.html

Below is a quick reproducible example, so long as the calling environment is using ggplot2 version 3.5.0.

packageVersion("ggplot2")

library(ggsurvfit)
result <- survfit2(Surv(time, status) ~ sex, data = df_lung) |>
  ggsurvfit() +
  add_risktable()
result
> packageVersion("ggplot2")
[1] ‘3.5.0’

Warning messages:
1: In ggplot2::geom_blank() :
  All aesthetics have length 1, but the data has 208 rows.
ℹ Did you mean to use `annotate()`?
2: In ggplot2::geom_blank() :
  All aesthetics have length 1, but the data has 208 rows.
ℹ Did you mean to use `annotate()`?
3: In ggplot2::geom_blank() :
  All aesthetics have length 1, but the data has 208 rows.
ℹ Did you mean to use `annotate()`?
ddsjoberg commented 3 months ago

Ooof, thank you for reporting @dereksonderegger !