From e32615b83208786806a4c23e560e6ffd0d2b27bc Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Mar 2026 14:34:29 +0100 Subject: [PATCH 1/5] Plot estimated means - why connecting lines between groups? Fixes #603 --- DESCRIPTION | 2 +- NEWS.md | 5 +++++ R/visualisation_recipe.R | 12 ++++++------ R/visualisation_recipe_internal.R | 2 +- man/visualisation_recipe.estimate_predicted.Rd | 10 +++++----- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c9d8c7f2c..0eaf096c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: modelbased Title: Estimation of Model-Based Predictions, Contrasts and Means -Version: 0.14.0.1 +Version: 0.14.0.2 Authors@R: c(person(given = "Dominique", family = "Makowski", diff --git a/NEWS.md b/NEWS.md index 1e9a2eece..8f00f3bd3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # modelbased (devel) +## Breaking Changes + +* Argument `join_dots` in the `plot()` method, which is used to connect dots + with lines, now defaults to `FALSE`. + ## Changes * Support for models of class `nestedLogit`. diff --git a/R/visualisation_recipe.R b/R/visualisation_recipe.R index 869b38d22..d1ebaa2c2 100644 --- a/R/visualisation_recipe.R +++ b/R/visualisation_recipe.R @@ -27,11 +27,11 @@ #' `collapse_group` argument to "collapse" data points by random effects #' grouping factors. Argument `show_data` will be ignored for plotting objects #' returned by `estimate_slopes()` or `estimate_grouplevel()`. -#' @param join_dots Logical, if `TRUE` (default) and for categorical focal terms -#' in `by`, dots (estimates) are connected by lines, i.e. plots will be a -#' combination of dots with error bars and connecting lines. If `FALSE`, only -#' dots and error bars are shown. It is possible to set a global default value -#' using `options()`, e.g. `options(modelbased_join_dots = FALSE)`. +#' @param join_dots Logical, if `TRUE` and for categorical focal terms in `by`, +#' dots (estimates) are connected by lines, i.e. plots will be a combination of +#' dots with error bars and connecting lines. If `FALSE` (default), only dots +#' and error bars are shown. It is possible to set a global default value using +#' `options()`, e.g. `options(modelbased_join_dots = TRUE)`. #' @param numeric_as_discrete Maximum number of unique values in a numeric #' predictor to treat that predictor as discrete. Defaults to `8`. Numeric #' predictors are usually mapped to a continuous color scale, unless they have @@ -203,7 +203,7 @@ visualisation_recipe.estimate_predicted <- function( # set defaults if (is.null(join_dots)) { - join_dots <- getOption("modelbased_join_dots", TRUE) + join_dots <- getOption("modelbased_join_dots", FALSE) } if (is.null(numeric_as_discrete)) { numeric_as_discrete <- getOption("modelbased_numeric_as_discrete", 8) diff --git a/R/visualisation_recipe_internal.R b/R/visualisation_recipe_internal.R index 9cd8bfc68..86b4bc14b 100644 --- a/R/visualisation_recipe_internal.R +++ b/R/visualisation_recipe_internal.R @@ -279,7 +279,7 @@ ribbon = NULL, facet = NULL, grid = NULL, - join_dots = TRUE, + join_dots = FALSE, numeric_as_discrete = 8, ... ) { diff --git a/man/visualisation_recipe.estimate_predicted.Rd b/man/visualisation_recipe.estimate_predicted.Rd index e836ee75e..9db3e8740 100644 --- a/man/visualisation_recipe.estimate_predicted.Rd +++ b/man/visualisation_recipe.estimate_predicted.Rd @@ -105,11 +105,11 @@ data points from residuals by random effects grouping factors.} \item{point, line, pointrange, ribbon, facet, grid}{Additional aesthetics and parameters for the geoms (see customization example).} -\item{join_dots}{Logical, if \code{TRUE} (default) and for categorical focal terms -in \code{by}, dots (estimates) are connected by lines, i.e. plots will be a -combination of dots with error bars and connecting lines. If \code{FALSE}, only -dots and error bars are shown. It is possible to set a global default value -using \code{options()}, e.g. \code{options(modelbased_join_dots = FALSE)}.} +\item{join_dots}{Logical, if \code{TRUE} and for categorical focal terms in \code{by}, +dots (estimates) are connected by lines, i.e. plots will be a combination of +dots with error bars and connecting lines. If \code{FALSE} (default), only dots +and error bars are shown. It is possible to set a global default value using +\code{options()}, e.g. \code{options(modelbased_join_dots = TRUE)}.} } \value{ An object of class \code{visualisation_recipe} that describes the layers From 1dc1be179a76682cb9a06d4998d90c5972ceaf6b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Mar 2026 14:41:44 +0100 Subject: [PATCH 2/5] update snaps --- .../plot-interaction-facets-cat-1.new.svg | 277 ++++++++++ .../plot-interaction-facets-cat-2.new.svg | 489 ++++++++++++++++++ ...ot-interaction-facets-cat-4emmeans.new.svg | 269 ++++++++++ ...ot-interaction-facets-cat-5emmeans.new.svg | 467 +++++++++++++++++ .../_snaps/plot-ordinal/plot-ordinal-3.svg | 10 - .../_snaps/plot-ordinal/plot-ordinal-4.svg | 10 - .../plot-ordinal/plot-ordinal-bracl.svg | 8 - .../plot-ordinal/plot-ordinal-nnet-2.svg | 10 - .../_snaps/plot-ordinal/plot-ordinal-nnet.svg | 8 - .../plot-show_data/plot-show-data-me1.svg | 1 - .../plot-show_data/plot-show-data-me2.svg | 1 - .../plot-show_data/plot-show-data-me3.svg | 1 - .../plot-show_data/plot-show-data-me4.svg | 1 - .../_snaps/plot-slopes/plot-slopes-brms-1.svg | 1 - .../plot-slopes-y-axis-labels-2.svg | 1 - .../_snaps/plot/plot-cat-num-predictor-1.svg | 1 - .../_snaps/plot/plot-cat-num-predictor-2.svg | 1 - .../_snaps/plot/plot-cat-num-predictor-3.svg | 1 - .../_snaps/plot/plot-cat-num-predictor-4.svg | 1 - .../_snaps/plot/plot-cat-num-predictor-5.svg | 1 - .../plot/plot-expectation-fivenum-2.svg | 5 - .../_snaps/plot/plot-expectation-fivenum.svg | 10 - .../testthat/_snaps/plot/plot-join-dots-1.svg | 2 - .../testthat/_snaps/plot/plot-join-dots-2.svg | 10 - .../_snaps/plot/plot-logistic-bounds-1.svg | 4 - .../testthat/_snaps/plot/plot-me-means-1.svg | 1 - .../testthat/_snaps/plot/plot-me-means-4.svg | 10 - .../_snaps/plot/plot-me-means-showdata-1.svg | 1 - .../_snaps/plot/plot-me-means-showdata-4.svg | 10 - tests/testthat/_snaps/plot/plot-means-1.svg | 1 - tests/testthat/_snaps/plot/plot-means-4.svg | 10 - .../_snaps/plot/plot-means-no-ci-1.svg | 1 - .../_snaps/plot/plot-means-poisson-1.svg | 1 - .../_snaps/plot/plot-means-poisson-2.svg | 1 - .../plot/plot-means-predictor-order-1.svg | 10 - .../plot/plot-means-predictor-order-3.svg | 10 - .../_snaps/plot/plot-means-showdata-1.svg | 1 - .../_snaps/plot/plot-means-showdata-4.svg | 10 - .../testthat/_snaps/plot/plot-relation-1.svg | 1 - .../testthat/_snaps/plot/plot-relation-4.svg | 6 - .../_snaps/plot/plot-relation-showdata-1.svg | 1 - .../_snaps/plot/plot-relation-showdata-4.svg | 6 - tests/testthat/_snaps/plot/plot-slopes-1.svg | 1 - tests/testthat/_snaps/plot/plot-slopes-3.svg | 1 - 44 files changed, 1502 insertions(+), 171 deletions(-) create mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg create mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg create mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg create mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg new file mode 100644 index 000000000..db6cf0aa6 --- /dev/null +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg @@ -0,0 +1,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +male + + + + + + + + + + +female + + + + + + + + + + +Care Level 1 + + + + + + + + + + +Care Level 2 + + + + + + + + + + +Care Level 3/3+ + + + + +Male +Female + + +Male +Female +-30 +-20 +-10 +0 +10 +20 + + + + + + +-30 +-20 +-10 +0 +10 +20 + + + + + + +-30 +-20 +-10 +0 +10 +20 + + + + + + +carer's gender +Mean of Negative impact with 7 items + +carer's level of education + + + + + + + + + +low level of education +intermediate level of education +high level of education +plot-interaction-facets-cat-1 + + diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg new file mode 100644 index 000000000..da74024fd --- /dev/null +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg @@ -0,0 +1,489 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +male + + + + + + + + + + +0 + + + + + + + + + + +male + + + + + + + + + + +1 + + + + + + + + + + +female + + + + + + + + + + +0 + + + + + + + + + + +female + + + + + + + + + + +1 + + + + + + + + + + +Care Level 1 + + + + + + + + + + +Care Level 2 + + + + + + + + + + +Care Level 3/3+ + + + + +Male +Female + + +Male +Female + + +Male +Female + + +Male +Female +-10 +0 +10 +20 +30 +40 + + + + + + +-10 +0 +10 +20 +30 +40 + + + + + + +-10 +0 +10 +20 +30 +40 + + + + + + +carer's gender +Mean of Negative impact with 7 items + +carer's level of education + + + + + + + + + +low level of education +intermediate level of education +high level of education +plot-interaction-facets-cat-2 + + diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg new file mode 100644 index 000000000..9e17009df --- /dev/null +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +male + + + + + + + + + + +female + + + + + + + + + + +Care Level 1 + + + + + + + + + + +Care Level 2 + + + + + + + + + + +Care Level 3/3+ + + + + +Male +Female + + +Male +Female +0 +5 +10 +15 +20 + + + + + +0 +5 +10 +15 +20 + + + + + +0 +5 +10 +15 +20 + + + + + +carer's gender +Mean of Negative impact with 7 items + +carer's level of education + + + + + + + + + +low level of education +intermediate level of education +high level of education +plot-interaction-facets-cat-4emmeans + + diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg new file mode 100644 index 000000000..9f374ef94 --- /dev/null +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg @@ -0,0 +1,467 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +male + + + + + + + + + + +0 + + + + + + + + + + +male + + + + + + + + + + +1 + + + + + + + + + + +female + + + + + + + + + + +0 + + + + + + + + + + +female + + + + + + + + + + +1 + + + + + + + + + + +Care Level 1 + + + + + + + + + + +Care Level 2 + + + + + + + + + + +Care Level 3/3+ + + + + +Male +Female + + +Male +Female + + +Male +Female + + +Male +Female +5 +10 +15 +20 + + + + +5 +10 +15 +20 + + + + +5 +10 +15 +20 + + + + +carer's gender +Mean of Negative impact with 7 items + +carer's level of education + + + + + + + + + +low level of education +intermediate level of education +high level of education +plot-interaction-facets-cat-5emmeans + + diff --git a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-3.svg b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-3.svg index 70be04558..74727135a 100644 --- a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-3.svg +++ b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-3.svg @@ -27,11 +27,6 @@ - - - - - @@ -78,23 +73,18 @@ Response - - - - - 1 diff --git a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-4.svg b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-4.svg index cc39d45e5..c12a77f4c 100644 --- a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-4.svg +++ b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-4.svg @@ -27,11 +27,6 @@ - - - - - @@ -72,23 +67,18 @@ Response - - - - - 1 diff --git a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-bracl.svg b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-bracl.svg index 80b3c4e40..6553f8ae2 100644 --- a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-bracl.svg +++ b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-bracl.svg @@ -27,10 +27,6 @@ - - - - @@ -69,19 +65,15 @@ Response - - - - definitely diff --git a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet-2.svg b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet-2.svg index 700ece971..a8ef14307 100644 --- a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet-2.svg +++ b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet-2.svg @@ -27,8 +27,6 @@ - - @@ -52,8 +50,6 @@ - - @@ -77,8 +73,6 @@ - - @@ -102,8 +96,6 @@ - - @@ -200,11 +192,9 @@ gender - - male diff --git a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet.svg b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet.svg index f2c891447..8a8db5488 100644 --- a/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet.svg +++ b/tests/testthat/_snaps/plot-ordinal/plot-ordinal-nnet.svg @@ -27,10 +27,6 @@ - - - - @@ -69,19 +65,15 @@ Response - - - - definitely diff --git a/tests/testthat/_snaps/plot-show_data/plot-show-data-me1.svg b/tests/testthat/_snaps/plot-show_data/plot-show-data-me1.svg index b8c439bae..827d6644e 100644 --- a/tests/testthat/_snaps/plot-show_data/plot-show-data-me1.svg +++ b/tests/testthat/_snaps/plot-show_data/plot-show-data-me1.svg @@ -917,7 +917,6 @@ - diff --git a/tests/testthat/_snaps/plot-show_data/plot-show-data-me2.svg b/tests/testthat/_snaps/plot-show_data/plot-show-data-me2.svg index 840c0a397..d56ba48a6 100644 --- a/tests/testthat/_snaps/plot-show_data/plot-show-data-me2.svg +++ b/tests/testthat/_snaps/plot-show_data/plot-show-data-me2.svg @@ -43,7 +43,6 @@ - diff --git a/tests/testthat/_snaps/plot-show_data/plot-show-data-me3.svg b/tests/testthat/_snaps/plot-show_data/plot-show-data-me3.svg index 2daf57f8e..f2c3b1699 100644 --- a/tests/testthat/_snaps/plot-show_data/plot-show-data-me3.svg +++ b/tests/testthat/_snaps/plot-show_data/plot-show-data-me3.svg @@ -917,7 +917,6 @@ - diff --git a/tests/testthat/_snaps/plot-show_data/plot-show-data-me4.svg b/tests/testthat/_snaps/plot-show_data/plot-show-data-me4.svg index f0bda7d62..d5d8c59a7 100644 --- a/tests/testthat/_snaps/plot-show_data/plot-show-data-me4.svg +++ b/tests/testthat/_snaps/plot-show_data/plot-show-data-me4.svg @@ -43,7 +43,6 @@ - diff --git a/tests/testthat/_snaps/plot-slopes/plot-slopes-brms-1.svg b/tests/testthat/_snaps/plot-slopes/plot-slopes-brms-1.svg index b6cd886a5..8c3b79345 100644 --- a/tests/testthat/_snaps/plot-slopes/plot-slopes-brms-1.svg +++ b/tests/testthat/_snaps/plot-slopes/plot-slopes-brms-1.svg @@ -28,7 +28,6 @@ - diff --git a/tests/testthat/_snaps/plot-slopes/plot-slopes-y-axis-labels-2.svg b/tests/testthat/_snaps/plot-slopes/plot-slopes-y-axis-labels-2.svg index 9d1061c27..3fb5f49bb 100644 --- a/tests/testthat/_snaps/plot-slopes/plot-slopes-y-axis-labels-2.svg +++ b/tests/testthat/_snaps/plot-slopes/plot-slopes-y-axis-labels-2.svg @@ -28,7 +28,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-cat-num-predictor-1.svg b/tests/testthat/_snaps/plot/plot-cat-num-predictor-1.svg index abe724c8a..df26d80d0 100644 --- a/tests/testthat/_snaps/plot/plot-cat-num-predictor-1.svg +++ b/tests/testthat/_snaps/plot/plot-cat-num-predictor-1.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-cat-num-predictor-2.svg b/tests/testthat/_snaps/plot/plot-cat-num-predictor-2.svg index be8c58b76..d001ba61c 100644 --- a/tests/testthat/_snaps/plot/plot-cat-num-predictor-2.svg +++ b/tests/testthat/_snaps/plot/plot-cat-num-predictor-2.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-cat-num-predictor-3.svg b/tests/testthat/_snaps/plot/plot-cat-num-predictor-3.svg index 7ffd2be38..65afbf233 100644 --- a/tests/testthat/_snaps/plot/plot-cat-num-predictor-3.svg +++ b/tests/testthat/_snaps/plot/plot-cat-num-predictor-3.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-cat-num-predictor-4.svg b/tests/testthat/_snaps/plot/plot-cat-num-predictor-4.svg index f70bf50dd..085ae2b4a 100644 --- a/tests/testthat/_snaps/plot/plot-cat-num-predictor-4.svg +++ b/tests/testthat/_snaps/plot/plot-cat-num-predictor-4.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-cat-num-predictor-5.svg b/tests/testthat/_snaps/plot/plot-cat-num-predictor-5.svg index ad5b5a6ad..0886f7f9f 100644 --- a/tests/testthat/_snaps/plot/plot-cat-num-predictor-5.svg +++ b/tests/testthat/_snaps/plot/plot-cat-num-predictor-5.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-expectation-fivenum-2.svg b/tests/testthat/_snaps/plot/plot-expectation-fivenum-2.svg index 8d1b062b3..becfcc16d 100644 --- a/tests/testthat/_snaps/plot/plot-expectation-fivenum-2.svg +++ b/tests/testthat/_snaps/plot/plot-expectation-fivenum-2.svg @@ -27,11 +27,6 @@ - - - - - diff --git a/tests/testthat/_snaps/plot/plot-expectation-fivenum.svg b/tests/testthat/_snaps/plot/plot-expectation-fivenum.svg index 169ec1735..9b8592cb4 100644 --- a/tests/testthat/_snaps/plot/plot-expectation-fivenum.svg +++ b/tests/testthat/_snaps/plot/plot-expectation-fivenum.svg @@ -27,11 +27,6 @@ - - - - - @@ -82,23 +77,18 @@ Petal.Width - - - - - 0.10 diff --git a/tests/testthat/_snaps/plot/plot-join-dots-1.svg b/tests/testthat/_snaps/plot/plot-join-dots-1.svg index 368c9a249..2566089d4 100644 --- a/tests/testthat/_snaps/plot/plot-join-dots-1.svg +++ b/tests/testthat/_snaps/plot/plot-join-dots-1.svg @@ -177,8 +177,6 @@ - - diff --git a/tests/testthat/_snaps/plot/plot-join-dots-2.svg b/tests/testthat/_snaps/plot/plot-join-dots-2.svg index 832f49bc1..93e57a716 100644 --- a/tests/testthat/_snaps/plot/plot-join-dots-2.svg +++ b/tests/testthat/_snaps/plot/plot-join-dots-2.svg @@ -177,16 +177,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-logistic-bounds-1.svg b/tests/testthat/_snaps/plot/plot-logistic-bounds-1.svg index c1a71d5eb..4772d6074 100644 --- a/tests/testthat/_snaps/plot/plot-logistic-bounds-1.svg +++ b/tests/testthat/_snaps/plot/plot-logistic-bounds-1.svg @@ -27,8 +27,6 @@ - - @@ -65,11 +63,9 @@ var1 - - 0 diff --git a/tests/testthat/_snaps/plot/plot-me-means-1.svg b/tests/testthat/_snaps/plot/plot-me-means-1.svg index 0403fdfc6..d15e6d182 100644 --- a/tests/testthat/_snaps/plot/plot-me-means-1.svg +++ b/tests/testthat/_snaps/plot/plot-me-means-1.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-me-means-4.svg b/tests/testthat/_snaps/plot/plot-me-means-4.svg index 0f7303cea..deaf059f3 100644 --- a/tests/testthat/_snaps/plot/plot-me-means-4.svg +++ b/tests/testthat/_snaps/plot/plot-me-means-4.svg @@ -27,16 +27,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-me-means-showdata-1.svg b/tests/testthat/_snaps/plot/plot-me-means-showdata-1.svg index 81cd24563..bd0227848 100644 --- a/tests/testthat/_snaps/plot/plot-me-means-showdata-1.svg +++ b/tests/testthat/_snaps/plot/plot-me-means-showdata-1.svg @@ -177,7 +177,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-me-means-showdata-4.svg b/tests/testthat/_snaps/plot/plot-me-means-showdata-4.svg index 1555af8b0..a3d8e1efe 100644 --- a/tests/testthat/_snaps/plot/plot-me-means-showdata-4.svg +++ b/tests/testthat/_snaps/plot/plot-me-means-showdata-4.svg @@ -177,16 +177,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-means-1.svg b/tests/testthat/_snaps/plot/plot-means-1.svg index 7f90e7833..eb7838441 100644 --- a/tests/testthat/_snaps/plot/plot-means-1.svg +++ b/tests/testthat/_snaps/plot/plot-means-1.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-means-4.svg b/tests/testthat/_snaps/plot/plot-means-4.svg index c69432ba4..dbcd4fd75 100644 --- a/tests/testthat/_snaps/plot/plot-means-4.svg +++ b/tests/testthat/_snaps/plot/plot-means-4.svg @@ -27,16 +27,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-means-no-ci-1.svg b/tests/testthat/_snaps/plot/plot-means-no-ci-1.svg index 639073e70..0303e6027 100644 --- a/tests/testthat/_snaps/plot/plot-means-no-ci-1.svg +++ b/tests/testthat/_snaps/plot/plot-means-no-ci-1.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-means-poisson-1.svg b/tests/testthat/_snaps/plot/plot-means-poisson-1.svg index 3d7a452ea..2cf82fd4b 100644 --- a/tests/testthat/_snaps/plot/plot-means-poisson-1.svg +++ b/tests/testthat/_snaps/plot/plot-means-poisson-1.svg @@ -127,7 +127,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-means-poisson-2.svg b/tests/testthat/_snaps/plot/plot-means-poisson-2.svg index dd62e0228..e46a6e1fb 100644 --- a/tests/testthat/_snaps/plot/plot-means-poisson-2.svg +++ b/tests/testthat/_snaps/plot/plot-means-poisson-2.svg @@ -127,7 +127,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-means-predictor-order-1.svg b/tests/testthat/_snaps/plot/plot-means-predictor-order-1.svg index 6f673f0dd..9725d47ca 100644 --- a/tests/testthat/_snaps/plot/plot-means-predictor-order-1.svg +++ b/tests/testthat/_snaps/plot/plot-means-predictor-order-1.svg @@ -27,16 +27,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-means-predictor-order-3.svg b/tests/testthat/_snaps/plot/plot-means-predictor-order-3.svg index 43adc7ced..5069addfa 100644 --- a/tests/testthat/_snaps/plot/plot-means-predictor-order-3.svg +++ b/tests/testthat/_snaps/plot/plot-means-predictor-order-3.svg @@ -27,16 +27,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-means-showdata-1.svg b/tests/testthat/_snaps/plot/plot-means-showdata-1.svg index c4b754740..c8e42401d 100644 --- a/tests/testthat/_snaps/plot/plot-means-showdata-1.svg +++ b/tests/testthat/_snaps/plot/plot-means-showdata-1.svg @@ -177,7 +177,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-means-showdata-4.svg b/tests/testthat/_snaps/plot/plot-means-showdata-4.svg index f98cc07be..12eccca75 100644 --- a/tests/testthat/_snaps/plot/plot-means-showdata-4.svg +++ b/tests/testthat/_snaps/plot/plot-means-showdata-4.svg @@ -177,16 +177,6 @@ - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-relation-1.svg b/tests/testthat/_snaps/plot/plot-relation-1.svg index 27d4a0275..0b106b4bd 100644 --- a/tests/testthat/_snaps/plot/plot-relation-1.svg +++ b/tests/testthat/_snaps/plot/plot-relation-1.svg @@ -27,7 +27,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-relation-4.svg b/tests/testthat/_snaps/plot/plot-relation-4.svg index 0fd7e46e5..3a2910071 100644 --- a/tests/testthat/_snaps/plot/plot-relation-4.svg +++ b/tests/testthat/_snaps/plot/plot-relation-4.svg @@ -27,12 +27,6 @@ - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-relation-showdata-1.svg b/tests/testthat/_snaps/plot/plot-relation-showdata-1.svg index c9247b699..5404ec65b 100644 --- a/tests/testthat/_snaps/plot/plot-relation-showdata-1.svg +++ b/tests/testthat/_snaps/plot/plot-relation-showdata-1.svg @@ -177,7 +177,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-relation-showdata-4.svg b/tests/testthat/_snaps/plot/plot-relation-showdata-4.svg index f5aad50de..636c9d51c 100644 --- a/tests/testthat/_snaps/plot/plot-relation-showdata-4.svg +++ b/tests/testthat/_snaps/plot/plot-relation-showdata-4.svg @@ -177,12 +177,6 @@ - - - - - - diff --git a/tests/testthat/_snaps/plot/plot-slopes-1.svg b/tests/testthat/_snaps/plot/plot-slopes-1.svg index 8873e711b..9c6614621 100644 --- a/tests/testthat/_snaps/plot/plot-slopes-1.svg +++ b/tests/testthat/_snaps/plot/plot-slopes-1.svg @@ -28,7 +28,6 @@ - diff --git a/tests/testthat/_snaps/plot/plot-slopes-3.svg b/tests/testthat/_snaps/plot/plot-slopes-3.svg index c3cfa3a54..f54b96518 100644 --- a/tests/testthat/_snaps/plot/plot-slopes-3.svg +++ b/tests/testthat/_snaps/plot/plot-slopes-3.svg @@ -28,7 +28,6 @@ - From 5337daa3f5db0b7d7d0b492461d4cf6f021b0868 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Mar 2026 14:44:09 +0100 Subject: [PATCH 3/5] add snaps --- .../_snaps/plot/plot-means-1-lines.svg | 60 +++++++ .../_snaps/plot/plot-means-4-lines.svg | 141 +++++++++++++++ .../plot/plot-means-poisson-1-lines.svg | 164 ++++++++++++++++++ tests/testthat/test-plot.R | 13 ++ 4 files changed, 378 insertions(+) create mode 100644 tests/testthat/_snaps/plot/plot-means-1-lines.svg create mode 100644 tests/testthat/_snaps/plot/plot-means-4-lines.svg create mode 100644 tests/testthat/_snaps/plot/plot-means-poisson-1-lines.svg diff --git a/tests/testthat/_snaps/plot/plot-means-1-lines.svg b/tests/testthat/_snaps/plot/plot-means-1-lines.svg new file mode 100644 index 000000000..1556beb65 --- /dev/null +++ b/tests/testthat/_snaps/plot/plot-means-1-lines.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +4.5 +5.0 +5.5 +6.0 +6.5 + + + + + + + + +setosa +versicolor +virginica +Species +Mean of Sepal.Length +plot-means-1-lines + + diff --git a/tests/testthat/_snaps/plot/plot-means-4-lines.svg b/tests/testthat/_snaps/plot/plot-means-4-lines.svg new file mode 100644 index 000000000..826a1aba6 --- /dev/null +++ b/tests/testthat/_snaps/plot/plot-means-4-lines.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +4 +5 +6 +7 +8 + + + + + + + + +setosa +versicolor +virginica +Species +Mean of Sepal.Length + +Sepal.Width + + + + + + + + + + + +2.0 +2.5 +3.0 +3.5 +4.0 +plot-means-4-lines + + diff --git a/tests/testthat/_snaps/plot/plot-means-poisson-1-lines.svg b/tests/testthat/_snaps/plot/plot-means-poisson-1-lines.svg new file mode 100644 index 000000000..7435d8ed6 --- /dev/null +++ b/tests/testthat/_snaps/plot/plot-means-poisson-1-lines.svg @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +2 +4 +6 +8 + + + + + + + + + +1 +2 +3 +4 +fa +Rate of y +plot-means-poisson-1-lines + + diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index b07eb2b86..a3403fdad 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -15,6 +15,10 @@ test_that("plots emmeans", { "plot-means-1", plot(modelbased::visualisation_recipe(x, show_data = FALSE)) ) + vdiffr::expect_doppelganger( + "plot-means-1-lines", + plot(modelbased::visualisation_recipe(x, show_data = FALSE, join_dots = TRUE)) + ) x <- estimate_means(model, by = "Sepal.Width", backend = "emmeans") vdiffr::expect_doppelganger( "plot-means-2", @@ -30,6 +34,10 @@ test_that("plots emmeans", { "plot-means-4", plot(modelbased::visualisation_recipe(x, show_data = FALSE)) ) + vdiffr::expect_doppelganger( + "plot-means-4-lines", + plot(modelbased::visualisation_recipe(x, show_data = FALSE, join_dots = TRUE)) + ) }) @@ -245,6 +253,11 @@ test_that("plots, estimate_means works with Poisson", { x <- estimate_means(dat_glm, "fa", backend = "emmeans") set.seed(123) vdiffr::expect_doppelganger("plot-means-poisson-1", plot(x, show_data = TRUE)) + set.seed(123) + vdiffr::expect_doppelganger( + "plot-means-poisson-1-lines", + plot(x, show_data = TRUE, join_dots = TRUE) + ) x <- estimate_means(dat_glm, "fa", backend = "marginaleffects") set.seed(123) vdiffr::expect_doppelganger("plot-means-poisson-2", plot(x, show_data = TRUE)) From de2300f9b3c8e82957b57262ae5ac83896e30479 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Mar 2026 14:59:23 +0100 Subject: [PATCH 4/5] fix test --- tests/testthat/test-visualisation_recipe.R | 72 +++++++++++++++++----- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/tests/testthat/test-visualisation_recipe.R b/tests/testthat/test-visualisation_recipe.R index f7d9eb207..42457caca 100644 --- a/tests/testthat/test-visualisation_recipe.R +++ b/tests/testthat/test-visualisation_recipe.R @@ -39,7 +39,6 @@ test_that("visualization_recipe", { expect_identical(aes$x, "Species") expect_identical(aes$color, "fac") - x <- estimate_means(model, by = c("Species", "Sepal.Width", "fac")) # plot(modelbased:::.visualization_recipe(x)) aes <- modelbased:::.find_aes(x)$aes @@ -52,38 +51,76 @@ test_that("visualization_recipe", { dat <- data.frame(y = rpois(100, 3), fa = gl(4, 20, 100)) dat_glm <- glm(y ~ fa, data = dat, family = poisson(link = "log")) x <- estimate_means(dat_glm, "fa", backend = "emmeans") - vr <- visualisation_recipe(x, show_data = TRUE) + vr <- visualisation_recipe(x, show_data = TRUE, join_dots = TRUE) expect_identical(vr$l1$aes, list(y = "y", x = "fa", color = NULL, alpha = NULL)) - expect_identical(vr$l2$aes, list(y = "Rate", x = "fa", color = NULL, alpha = NULL, group = ".group")) + expect_identical( + vr$l2$aes, + list(y = "Rate", x = "fa", color = NULL, alpha = NULL, group = ".group") + ) expect_identical( vr$l3$aes, list( - y = "Rate", x = "fa", ymin = "CI_low", ymax = "CI_high", - color = NULL, group = ".group", alpha = NULL + y = "Rate", + x = "fa", + ymin = "CI_low", + ymax = "CI_high", + color = NULL, + group = ".group", + alpha = NULL ) ) + vr <- visualisation_recipe(x, show_data = TRUE, join_dots = FALSE) + expect_identical(vr$l1$aes, list(y = "y", x = "fa", color = NULL, alpha = NULL)) + expect_identical( + vr$l2$aes, + list( + y = "Rate", + x = "fa", + ymin = "CI_low", + ymax = "CI_high", + color = NULL, + group = ".group", + alpha = NULL + ) + ) + expect_null(vr$l3$aes) x <- estimate_means(dat_glm, "fa", backend = "marginaleffects") - vr <- visualisation_recipe(x, show_data = TRUE) + vr <- visualisation_recipe(x, show_data = TRUE, join_dots = TRUE) expect_identical(vr$l1$aes, list(y = "y", x = "fa", color = NULL, alpha = NULL)) - expect_identical(vr$l2$aes, list(y = "Mean", x = "fa", color = NULL, alpha = NULL, group = ".group")) + expect_identical( + vr$l2$aes, + list(y = "Mean", x = "fa", color = NULL, alpha = NULL, group = ".group") + ) expect_identical( vr$l3$aes, list( - y = "Mean", x = "fa", ymin = "CI_low", ymax = "CI_high", - color = NULL, group = ".group", alpha = NULL + y = "Mean", + x = "fa", + ymin = "CI_low", + ymax = "CI_high", + color = NULL, + group = ".group", + alpha = NULL ) ) - vr <- visualisation_recipe(x, show_data = FALSE) - expect_identical(vr$l1$aes, list(y = "Mean", x = "fa", color = NULL, alpha = NULL, group = ".group")) + vr <- visualisation_recipe(x, show_data = FALSE, join_dots = TRUE) + expect_identical( + vr$l1$aes, + list(y = "Mean", x = "fa", color = NULL, alpha = NULL, group = ".group") + ) expect_identical( vr$l2$aes, list( - y = "Mean", x = "fa", ymin = "CI_low", ymax = "CI_high", - color = NULL, group = ".group", alpha = NULL + y = "Mean", + x = "fa", + ymin = "CI_low", + ymax = "CI_high", + color = NULL, + group = ".group", + alpha = NULL ) ) - # Estimate predictions --------------------------- x <- estimate_relation(model, by = "Sepal.Width") # plot(modelbased:::.visualization_recipe(x)) @@ -158,7 +195,12 @@ test_that("visualization_recipe", { expect_identical(aes$x, "Species") expect_null(aes$color) - x <- estimate_slopes(model, trend = "Species", by = "Sepal.Width", backend = "marginaleffects") + x <- estimate_slopes( + model, + trend = "Species", + by = "Sepal.Width", + backend = "marginaleffects" + ) aes <- modelbased:::.find_aes(x)$aes expect_identical(aes$y, "Slope") expect_identical(aes$x, "Sepal.Width") From a4abdbd6bbf4e2090134c139821e4aaee7d0e583 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 2 Mar 2026 15:02:48 +0100 Subject: [PATCH 5/5] update snaps/tests --- ...> plot-interaction-facets-cat-1-lines.svg} | 23 +- .../plot-interaction-facets-cat-1.svg | 21 - .../plot-interaction-facets-cat-2.svg | 39 -- ...> plot-interaction-facets-cat-3-lines.svg} | 41 +- ...ot-interaction-facets-cat-4emmeans.new.svg | 269 ---------- .../plot-interaction-facets-cat-4emmeans.svg | 20 - ...ot-interaction-facets-cat-5emmeans.new.svg | 467 ------------------ tests/testthat/test-plot-facet.R | 76 ++- 8 files changed, 95 insertions(+), 861 deletions(-) rename tests/testthat/_snaps/plot-facet/{plot-interaction-facets-cat-1.new.svg => plot-interaction-facets-cat-1-lines.svg} (90%) rename tests/testthat/_snaps/plot-facet/{plot-interaction-facets-cat-2.new.svg => plot-interaction-facets-cat-3-lines.svg} (89%) delete mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg delete mode 100644 tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1-lines.svg similarity index 90% rename from tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg rename to tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1-lines.svg index db6cf0aa6..eb3dd4123 100644 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.new.svg +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1-lines.svg @@ -27,6 +27,9 @@ + + + @@ -50,6 +53,9 @@ + + + @@ -73,6 +79,9 @@ + + + @@ -96,6 +105,9 @@ + + + @@ -119,6 +131,9 @@ + + + @@ -142,6 +157,9 @@ + + + @@ -261,17 +279,20 @@ carer's level of education + + + low level of education intermediate level of education high level of education -plot-interaction-facets-cat-1 +plot-interaction-facets-cat-1-lines diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.svg index 56658578b..db6cf0aa6 100644 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.svg +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-1.svg @@ -27,9 +27,6 @@ - - - @@ -53,9 +50,6 @@ - - - @@ -79,9 +73,6 @@ - - - @@ -105,9 +96,6 @@ - - - @@ -131,9 +119,6 @@ - - - @@ -157,9 +142,6 @@ - - - @@ -279,15 +261,12 @@ carer's level of education - - - low level of education diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.svg index a2c87e1b2..da74024fd 100644 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.svg +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.svg @@ -27,9 +27,6 @@ - - - @@ -53,9 +50,6 @@ - - - @@ -79,9 +73,6 @@ - - - @@ -105,9 +96,6 @@ - - - @@ -131,9 +119,6 @@ - - - @@ -157,9 +142,6 @@ - - - @@ -183,9 +165,6 @@ - - - @@ -209,9 +188,6 @@ - - - @@ -235,9 +211,6 @@ - - - @@ -261,9 +234,6 @@ - - - @@ -287,9 +257,6 @@ - - - @@ -313,9 +280,6 @@ - - - @@ -509,15 +473,12 @@ carer's level of education - - - low level of education diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-3-lines.svg similarity index 89% rename from tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg rename to tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-3-lines.svg index da74024fd..8ea3cee22 100644 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-2.new.svg +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-3-lines.svg @@ -27,6 +27,9 @@ + + + @@ -50,6 +53,9 @@ + + + @@ -73,6 +79,9 @@ + + + @@ -96,6 +105,9 @@ + + + @@ -119,6 +131,9 @@ + + + @@ -142,6 +157,9 @@ + + + @@ -165,6 +183,9 @@ + + + @@ -188,6 +209,9 @@ + + + @@ -211,6 +235,9 @@ + + + @@ -234,6 +261,9 @@ + + + @@ -257,6 +287,9 @@ + + + @@ -280,6 +313,9 @@ + + + @@ -473,17 +509,20 @@ carer's level of education + + + low level of education intermediate level of education high level of education -plot-interaction-facets-cat-2 +plot-interaction-facets-cat-3-lines diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg deleted file mode 100644 index 9e17009df..000000000 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.new.svg +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -male - - - - - - - - - - -female - - - - - - - - - - -Care Level 1 - - - - - - - - - - -Care Level 2 - - - - - - - - - - -Care Level 3/3+ - - - - -Male -Female - - -Male -Female -0 -5 -10 -15 -20 - - - - - -0 -5 -10 -15 -20 - - - - - -0 -5 -10 -15 -20 - - - - - -carer's gender -Mean of Negative impact with 7 items - -carer's level of education - - - - - - - - - -low level of education -intermediate level of education -high level of education -plot-interaction-facets-cat-4emmeans - - diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.svg index 1e91fc6a9..9e17009df 100644 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.svg +++ b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-4emmeans.svg @@ -27,9 +27,6 @@ - - - @@ -53,9 +50,6 @@ - - - @@ -79,8 +73,6 @@ - - @@ -102,9 +94,6 @@ - - - @@ -128,9 +117,6 @@ - - - @@ -154,9 +140,6 @@ - - - @@ -270,15 +253,12 @@ carer's level of education - - - low level of education diff --git a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg b/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg deleted file mode 100644 index 9f374ef94..000000000 --- a/tests/testthat/_snaps/plot-facet/plot-interaction-facets-cat-5emmeans.new.svg +++ /dev/null @@ -1,467 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -male - - - - - - - - - - -0 - - - - - - - - - - -male - - - - - - - - - - -1 - - - - - - - - - - -female - - - - - - - - - - -0 - - - - - - - - - - -female - - - - - - - - - - -1 - - - - - - - - - - -Care Level 1 - - - - - - - - - - -Care Level 2 - - - - - - - - - - -Care Level 3/3+ - - - - -Male -Female - - -Male -Female - - -Male -Female - - -Male -Female -5 -10 -15 -20 - - - - -5 -10 -15 -20 - - - - -5 -10 -15 -20 - - - - -carer's gender -Mean of Negative impact with 7 items - -carer's level of education - - - - - - - - - -low level of education -intermediate level of education -high level of education -plot-interaction-facets-cat-5emmeans - - diff --git a/tests/testthat/test-plot-facet.R b/tests/testthat/test-plot-facet.R index 4f22891ce..e8b367872 100644 --- a/tests/testthat/test-plot-facet.R +++ b/tests/testthat/test-plot-facet.R @@ -15,74 +15,44 @@ test_that("plots facets", { pr <- estimate_means(fit, c("c12hour", "c172code", "c161sex")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-1", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-1", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c172code", "barthtot")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-2", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-2", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c172code", "c161sex", "barthtot")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-3", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-3", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c172code", "barthtot", "c161sex")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-4", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-4", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "barthtot", "c161sex", "c172code")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-5", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-5", plot(pr, show_data = FALSE)) fit <- lm(neg_c_7 ~ c12hour * barthtot * c161sex * c172code * e16sex, data = efc) set.seed(123) pr <- estimate_means(fit, c("c12hour", "barthtot", "c161sex", "c172code", "e16sex")) - vdiffr::expect_doppelganger( - "plot-interaction-facets-6", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-6", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c161sex", "c172code", "e16sex", "barthtot")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-7", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-7", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c172code", "c161sex", "barthtot")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-8", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-8", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "c172code", "barthtot", "c161sex")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-9", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-9", plot(pr, show_data = FALSE)) pr <- estimate_means(fit, c("c12hour", "e16sex", "c161sex", "c172code")) set.seed(123) - vdiffr::expect_doppelganger( - "plot-interaction-facets-10", - plot(pr, show_data = FALSE) - ) + vdiffr::expect_doppelganger("plot-interaction-facets-10", plot(pr, show_data = FALSE)) }) @@ -98,6 +68,11 @@ test_that("plots facets", { "plot-interaction-facets-cat-1", plot(pr, show_data = FALSE) ) + set.seed(123) + vdiffr::expect_doppelganger( + "plot-interaction-facets-cat-1-lines", + plot(pr, show_data = FALSE, join_dots = TRUE) + ) fit <- lm(neg_c_7 ~ c161sex * c172code * e16sex * nur_pst * negc7d, data = efc) pr <- estimate_means(fit, c("c161sex", "c172code", "e16sex", "nur_pst", "negc7d")) @@ -106,6 +81,12 @@ test_that("plots facets", { "plot-interaction-facets-cat-2", plot(pr, show_data = FALSE) ) + # connecting lines + set.seed(123) + vdiffr::expect_doppelganger( + "plot-interaction-facets-cat-3-lines", + plot(pr, show_data = FALSE, join_dots = TRUE) + ) # no connecting lines set.seed(123) vdiffr::expect_doppelganger( @@ -121,7 +102,11 @@ test_that("plots facets, emmeans", { efc <- datawizard::to_factor(efc, c("c161sex", "c172code", "e16sex", "nur_pst")) fit <- lm(neg_c_7 ~ c161sex * c172code * e16sex * nur_pst, data = efc) - pr <- estimate_means(fit, c("c161sex", "c172code", "e16sex", "nur_pst"), backend = "emmeans") + pr <- estimate_means( + fit, + c("c161sex", "c172code", "e16sex", "nur_pst"), + backend = "emmeans" + ) set.seed(123) vdiffr::expect_doppelganger( "plot-interaction-facets-cat-4emmeans", @@ -129,11 +114,16 @@ test_that("plots facets, emmeans", { ) fit <- lm(neg_c_7 ~ c161sex * c172code * e16sex * nur_pst * negc7d, data = efc) - pr <- estimate_means(fit, c("c161sex", "c172code", "e16sex", "nur_pst", "negc7d"), backend = "emmeans") + pr <- estimate_means( + fit, + c("c161sex", "c172code", "e16sex", "nur_pst", "negc7d"), + backend = "emmeans" + ) + # connecting lines set.seed(123) vdiffr::expect_doppelganger( "plot-interaction-facets-cat-5emmeans", - plot(pr, show_data = FALSE) + plot(pr, show_data = FALSE, join_dots = TRUE) ) # no connecting lines set.seed(123)