Search code examples
rggplot2boxplot

Issue with `gghdr` package not producing HDR boxplots


I am currently experiencing an issue with the gghdr package in R. I'm trying to generate HDR boxplots, but I keep getting an error message. The code I'm using is as follows:

library(ggplot2)
library(gghdr)
ggplot(faithful, aes(y = eruptions)) +
  geom_hdr_boxplot()

However, when I run this code, I get the following error message:

Error in if (guide$reverse) { : argument is of length zero
In addition: Warning message:
The following aesthetics were dropped during statistical transformation: y.
ℹ This can happen when ggplot fails to infer the correct grouping structure in the data.
ℹ Did you forget to specify a `group` aesthetic or to convert a numerical variable into a
  factor?

If anyone could provide some insight into what might be causing this issue and how I can fix it, I would greatly appreciate it.

Thank you!


Solution

  • You can install the proposed fix from github with pak::pak("Sayani07/gghdr#25"). Disclaimer: I'm the one that proposed this fix. You'll be greeted by a wall of warnings, but it should work.

    # pak::pak("Sayani07/gghdr#25")
    
    library(ggplot2)
    library(gghdr)
    
    ggplot(faithful, aes(y = eruptions)) +
      geom_hdr_boxplot()
    #> Warning: The dot-dot notation (`..prob..`) was deprecated in ggplot2 3.4.0.
    #> ℹ Please use `after_stat(prob)` instead.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Warning: The following aesthetics were dropped during statistical transformation: y.
    #> ℹ This can happen when ggplot fails to infer the correct grouping structure in
    #>   the data.
    #> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
    #>   variable into a factor?
    #> Warning: The `scale_name` argument of `discrete_scale()` is deprecated as of ggplot2
    #> 3.5.0.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Warning: The S3 guide system was deprecated in ggplot2 3.5.0.
    #> ℹ It has been replaced by a ggproto system that can be extended.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Warning: Unknown or uninitialised column: `linewidth`.
    #> Warning: Using the `size` aesthetic with geom_rect was deprecated in ggplot2 3.4.0.
    #> ℹ Please use the `linewidth` aesthetic instead.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    #> Warning: Unknown or uninitialised column: `linewidth`.
    #> Warning: Using the `size` aesthetic with geom_segment was deprecated in ggplot2 3.4.0.
    #> ℹ Please use the `linewidth` aesthetic instead.
    #> This warning is displayed once every 8 hours.
    #> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
    #> generated.
    

    Created on 2024-05-07 with reprex v2.1.0