Closed stamats closed 1 year ago
I added dropped_aes = c("sample") to stat_pp_band, stat_pp_line, stat_qq_band, stat_qq_line in a fork of your repository and the warnings disappeared. Best Matthias
I have the same issue with my package rempsyc
that relies on qqplotr
.
library(rempsyc)
nice_qq(
data = iris,
variable = "Sepal.Length",
group = "Species"
)
#> Warning: The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
#> The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
#> The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
#> The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
#> The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
#> The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
Created on 2022-12-05 with reprex v2.0.2
Here is a minimal example of the issue and my attempt at the fix suggested by Matthias:
library(ggplot2)
library(qqplotr)
smp <- data.frame(norm = rnorm(100))
ggplot(data = smp, mapping = aes(sample = norm)) +
stat_qq_band()
#> Warning: The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
ggplot(data = smp, mapping = aes(sample = norm)) +
stat_qq_band(dropped_aes = "sample")
#> Warning in stat_qq_band(dropped_aes = "sample"): Ignoring unknown parameters:
#> `dropped_aes`
#> Warning: The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
ggplot(data = smp, mapping = aes(sample = norm)) +
stat_qq_band(mapping = aes(dropped_aes = "sample"))
#> Warning in stat_qq_band(dropped_aes = "sample"): Ignoring unknown parameters:
#> `dropped_aes`
#> Warning: The following aesthetics were dropped during statistical transformation: sample
#> ℹ 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?
Created on 2022-12-05 with reprex v2.0.2
We can see that stat_qq_band
does not accept dropped_aes = "sample"
as argument (I thought it would either as part of the ...
or mapping
arguments). Maybe it can only be fixed through the package code, with no workarounds for now.
@stamats can you submit your functional fork as a PR? Then @aloy might be able to accept it quickly (if there are no bugs).
I have generated a PR. Best Matthias
@stamats, PR has been merged
Thanks for your contribution!
@aloy any plans to submit the new version to CRAN? FYI I have to wait for that to submit the new version of rempsyc
and I'm sure it's the same for your other reverse dependencies.
@rempsyc , I plan to submit to CRAN today or tomorrow.
I use R 4.2.2 Patched (2022-11-12 r83339), ggplot2 version 3.4.0 (2022-11-04) and qqplotr 0.0.5 (2021-04-23).
Running your example: smp <- data.frame(norm = rnorm(100)) gg <- ggplot(data = smp, mapping = aes(sample = norm)) + stat_qq_band() + stat_qq_line() + stat_qq_point() + labs(x = "Theoretical Quantiles", y = "Sample Quantiles") gg
I now get two warnings:
1: The following aesthetics were dropped during statistical transformation: sample ℹ 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? 2: The following aesthetics were dropped during statistical transformation: sample ℹ This can happen when ggplot fails to infer the correct grouping structure in the data. ℹ Did you forget to specify agroup
aesthetic or to convert a numerical variable into a factor?Which are from stat_qq_band and stat_qq_line. That is
ggplot(data = smp, mapping = aes(sample = norm)) + stat_qq_band()
and
ggplot(data = smp, mapping = aes(sample = norm)) + stat_qq_line()
give a warning, but not
ggplot(data = smp, mapping = aes(sample = norm)) + stat_qq_point()
I have to admit that I'm not sure whether it is an issue with your package or ggplot2.
Best wishes Matthias