From 63366da9b92c089f50bd740eb0a1f027c71afada Mon Sep 17 00:00:00 2001 From: yjunechoe Date: Fri, 18 Oct 2024 13:33:54 -0400 Subject: [PATCH] update readme --- README.Rmd | 8 ++++++++ README.md | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.Rmd b/README.Rmd index 26708a5..e38e1df 100644 --- a/README.Rmd +++ b/README.Rmd @@ -153,6 +153,12 @@ The error tells us that the geom is missing some missing aesthetics, so somethin layer_before_geom(last_plot(), i = 2L, error = TRUE, verbose = TRUE) ``` +Note that you can more conveniently call `last_layer_errorcontext()` to the same effect: + +```{r boxplot-last_layer_errorcontext} +last_layer_errorcontext() +``` + Thus, we need to ensure that `y` exists to satisfy both the stat and the geom, and that `label` exists after the statistical transformation step but before the geom sees the data. Crucially, we use the computed variable `ymax` to (re-)map to the `y` and `label` aesthetics. ```{r boxplot-anno-success} @@ -206,6 +212,8 @@ Note that as of [{ggtrace} v0.7.1](https://github.com/yjunechoe/ggtrace/releases It's interesting to note that this is also possible in "vanilla" ggplot. Following our earlier discussion of `after_stat()`: ```{r boxplot-remove-outliers-after-stat} +# NOTE: outdated solution - superseded by `outliers = FALSE` in ggplot >=v3.5.0 + # Suppress warning from mapping to `outliers` aesthetic update_geom_defaults("boxplot", list(outliers = NULL)) diff --git a/README.md b/README.md index 5fd4ac9..368813f 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,20 @@ inspect this using `layer_before_geom()`, we find that the columns for #> # ℹ 4 more variables: relvarwidth , flipped_aes , PANEL , #> # group +Note that you can more conveniently call `last_layer_errorcontext()` to +the same effect: + + last_layer_errorcontext() + #> ✔ Executed `inspect_args(p, ggplot2:::Layer$compute_geom_1, layer_is(2L), error = TRUE, x = last_plot())$data` + #> # A tibble: 3 × 14 + #> ymin lower middle upper ymax outliers notchupper notchlower x width + #> + #> 1 21.4 22.8 26 30.4 33.9 29.6 22.4 1 0.75 + #> 2 17.8 18.6 19.7 21 21.4 21.1 18.3 2 0.75 + #> 3 13.3 14.4 15.2 16.2 18.7 16.0 14.4 3 0.75 + #> # ℹ 4 more variables: relvarwidth , flipped_aes , PANEL , + #> # group + Thus, we need to ensure that `y` exists to satisfy both the stat and the geom, and that `label` exists after the statistical transformation step but before the geom sees the data. Crucially, we use the computed @@ -290,6 +304,8 @@ v0.7.1](https://github.com/yjunechoe/ggtrace/releases/tag/v0.7.1), all It’s interesting to note that this is also possible in “vanilla” ggplot. Following our earlier discussion of `after_stat()`: + # NOTE: outdated solution - superseded by `outliers = FALSE` in ggplot >=v3.5.0 + # Suppress warning from mapping to `outliers` aesthetic update_geom_defaults("boxplot", list(outliers = NULL))