“gghdr”包不生成 HDR 箱线图的问题

问题描述 投票:0回答:1

我目前在 R 中遇到 gghdr 包的问题。我正在尝试生成 HDR 箱线图,但不断收到错误消息。我使用的代码如下:

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

但是,当我运行此代码时,我收到以下错误消息:

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?

如果有人能够提供一些有关可能导致此问题的原因以及如何解决它的见解,我将不胜感激。

谢谢!

r ggplot2 boxplot
1个回答
0
投票

您可以使用

pak::pak("Sayani07/gghdr#25")
从 github 安装建议的修复程序。免责声明:我是提出此修复程序的人。你会看到一堵警告墙,但它应该可以工作。

# 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.

创建于 2024-05-07,使用 reprex v2.1.0

© www.soinside.com 2019 - 2024. All rights reserved.