Skip to content

Commit b4e1826

Browse files
authored
Error in model_parameters.aov plot() method? (#376)
* Error in model_parameters.aov plot() method? Fixes #286 * fix
1 parent e8ecf7b commit b4e1826

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: see
33
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
4-
Version: 0.9.0.12
4+
Version: 0.9.0.13
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

NEWS.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
- `plot()` for `model_parameters()` gets a `show_direction` argument, to turn
1212
off the direction of the effect in the plot.
1313

14+
- `plot()` for `model_parameters()` now gives an informative error message when
15+
trying to plot Anova tables (which does not work).
16+
1417
- `plot()` for `simulate_parameters()` now better copes with models that have
1518
multiple response levels (e.g. multinomial models).
16-
19+
1720
- Gains `{patchwork}` as a hard dependency given its importance for the package.
1821

1922
## Bug fixes

R/plot.parameters_model.R

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ plot.see_parameters_model <- function(x,
6565
# retrieve settings ----------------
6666
model_attributes <- attributes(x)[!names(attributes(x)) %in% c("names", "row.names", "class")]
6767

68+
# no plot for anova
69+
model_class <- attributes(x)$model_class
70+
if (!is.null(model_class) && any(model_class %in% c("aov", "anova"))) {
71+
insight::format_error("Plots cannot be created for Anova tables. Please fit a (linear) regression model and try again.") # nolint
72+
}
73+
6874
# for GAMs, remove smooth terms
6975
if (!is.null(x$Component) && any(x$Component == "smooth_terms")) {
7076
x <- x[x$Component != "smooth_terms", ]

tests/testthat/test-plot.parameters_model.R

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ test_that("`plot.see_parameters_model()` works", {
1414
)
1515
})
1616

17+
18+
test_that("`plot.see_parameters_model()` errors for anova tables", {
19+
skip_if_not_installed("parameters")
20+
data(iris)
21+
m <- aov(Sepal.Length ~ Species, data = iris)
22+
mp <- parameters::model_parameters(m)
23+
expect_error(plot(mp), regex = "Plots cannot be created")
24+
})
25+
26+
1727
test_that("`plot.see_parameters_model()` random parameters works", {
1828
skip_if_not_installed("lme4")
1929
skip_if_not_installed("parameters")

0 commit comments

Comments
 (0)