From ab797addc9480f9bed87874f8b1cf0d600e2e055 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 15 Mar 2024 10:07:17 +0100 Subject: [PATCH] like that? --- tests/testthat/test-include_reference.R | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-include_reference.R b/tests/testthat/test-include_reference.R index b31cfc37f..8e63890e8 100644 --- a/tests/testthat/test-include_reference.R +++ b/tests/testthat/test-include_reference.R @@ -1,3 +1,5 @@ +skip_if_not_installed("tinytable") + test_that("include_reference, on-the-fly factors", { data(mtcars) d <- as.data.frame(mtcars) @@ -16,13 +18,23 @@ test_that("include_reference, on-the-fly factors", { expect_equal(attributes(out1)$pretty_names, attributes(out2)$pretty_names, ignore_attr = TRUE) expect_equal(out1$Coefficient, out2$Coefficient, tolerance = 1e-4) - skip_if_not_installed("tinytable") out <- compare_parameters(m1, m2, include_reference = TRUE) expect_snapshot(print_md(out, engine = "tt")) +}) + +skip_if(getRversion() < "4.3.3") +skip_if_not_installed("datawizard") + +test_that("include_reference, on-the-fly factors", { + data(mtcars) + d <- as.data.frame(mtcars) + d$gear <- as.factor(d$gear) + d$am <- as.factor(d$am) + m1 <- lm(mpg ~ as.factor(gear) + factor(am) + hp, data = mtcars) + m2 <- lm(mpg ~ gear + am + hp, data = d) - skip_if(getRversion() < "4.3.3") - skip_if_not_installed("datawizard") + out1 <- model_parameters(m1, include_reference = TRUE) out3 <- mtcars |> datawizard::data_modify(gear = factor(gear), am = as.factor(am)) |> lm(mpg ~ gear + am + hp, data = _) |>