From 9cf8d772e8d6518a22594f4ca9010cabd58e09c5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 6 Sep 2024 11:14:15 +0200 Subject: [PATCH] give informative error for invald input --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ R/plot.p_function.R | 6 ++++++ vignettes/parameters.Rmd | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aead763dd..8f12403ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: see Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2' -Version: 0.9.0 +Version: 0.9.0.1 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index bf61ca065..d0c299923 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# see (development) + +## Changes + +- `plot()` for `p_function()` now checks the values of the `size_length` + argument, to give an informative error message when the input is not valid. + # see 0.9.0 ## Changes diff --git a/R/plot.p_function.R b/R/plot.p_function.R index e6f4e3a5e..878fe08d1 100644 --- a/R/plot.p_function.R +++ b/R/plot.p_function.R @@ -55,6 +55,12 @@ plot.see_p_function <- function(x, # make sure group is factor data_ci_segments$group <- as.factor(data_ci_segments$group) + # sanity check - size_line must be of length two, when we have more than + # one group (i.e. when we emphasize CI lines) + if (length(size_line) != 2 && insight::n_unique(data_ci_segments$group) == 2) { + insight::format_error("Length of `size_line` must of length 2, to match regular and emphasized interval lines.") # nolint + } + # setup - no color/fill aes for ribbons when we have no facets if (!is.null(n_columns) || insight::n_unique(data_ribbon$Parameter) == 1) { p <- ggplot2::ggplot() + diff --git a/vignettes/parameters.Rmd b/vignettes/parameters.Rmd index aea10eb81..ad1c8e545 100644 --- a/vignettes/parameters.Rmd +++ b/vignettes/parameters.Rmd @@ -426,7 +426,7 @@ result <- p_function(model) plot(result) result <- p_function(model, ci_levels = c(0.5, 0.7, emph = 0.9)) -plot(result, size_line = 0.6, 1.0) +plot(result, size_line = c(0.6, 1.2)) ``` ## Principal Component Analysis