From d9558236cca841200cbf91f09236f0dd57de5282 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Nov 2024 08:52:08 +0100 Subject: [PATCH] add snapshot --- tests/testthat/_snaps/printing2.md | 34 ++++++++++++++++++++++++++++++ tests/testthat/test-printing2.R | 34 +++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/tests/testthat/_snaps/printing2.md b/tests/testthat/_snaps/printing2.md index 088c53ee8..6e9f663db 100644 --- a/tests/testthat/_snaps/printing2.md +++ b/tests/testthat/_snaps/printing2.md @@ -141,6 +141,40 @@ ------------------------------------------------------------------------------------------- Observations | 150 | | 150 | +--- + + Code + print(out, groups = list(Species = c("Species [versicolor]", + "Species [virginica]"), Interactions = c( + "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length"), + Controls = "Petal Length"), select = "{estimate}|{p}") + Output + Parameter | Estimate (lm1) | p (lm1) + ---------------------------------------------------------------- + Species | | + Species [versicolor] | -1.60 | <0.001 + Species [virginica] | -2.12 | <0.001 + Interactions | | + Species [versicolor] * Petal Length | | + Species [virginica] * Petal Length | | + Controls | | + Petal Length | 0.90 | <0.001 + ---------------------------------------------------------------- + Observations | 150 | + + Parameter | Estimate (lm2) | p (lm2) + ---------------------------------------------------------------- + Species | | + Species [versicolor] | -1.69 | 0.003 + Species [virginica] | -1.19 | 0.048 + Interactions | | + Species [versicolor] * Petal Length | -0.01 | 0.961 + Species [virginica] * Petal Length | -0.15 | 0.574 + Controls | | + Petal Length | 0.39 | 0.138 + ---------------------------------------------------------------- + Observations | 150 | + # combination of different models Code diff --git a/tests/testthat/test-printing2.R b/tests/testthat/test-printing2.R index 57c186e6e..8e932fdb2 100644 --- a/tests/testthat/test-printing2.R +++ b/tests/testthat/test-printing2.R @@ -2,7 +2,7 @@ skip_if_not_installed("withr") skip_if(getRversion() < "4.0.0") withr::with_options( - list(parameters_interaction = "*"), + list(parameters_interaction = "*", easystats_table_width = Inf), { lm1 <- lm(Sepal.Length ~ Species, data = iris) lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) @@ -66,7 +66,7 @@ withr::with_options( "Species [virginica]" ), Interactions = c( - "Species [versicolor] * Petal Length", # note the unicode char! + "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length" ), Controls = "Petal Length" @@ -79,7 +79,7 @@ withr::with_options( "Species [virginica]" ), Interactions = c( - "Species [versicolor] * Petal Length", # note the unicode char! + "Species [versicolor] * Petal Length", "Species [virginica] * Petal Length" ), Controls = "Petal Length" @@ -112,3 +112,31 @@ withr::with_options( }) } ) + + +withr::with_options( + list(parameters_interaction = "*"), + { + lm1 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) + lm2 <- lm(Sepal.Width ~ Species * Petal.Length, data = iris) + + # remove intercept + out <- compare_parameters(lm1, lm2, drop = "^\\(Intercept") + + test_that("templates, glue-3, separate columnns", { + expect_snapshot( + print(out, groups = list( + Species = c( + "Species [versicolor]", + "Species [virginica]" + ), + Interactions = c( + "Species [versicolor] * Petal Length", + "Species [virginica] * Petal Length" + ), + Controls = "Petal Length" + ), select = "{estimate}|{p}") + ) + }) + } +)