From 1cb741f9e7d16cb007c771c4901b2e0437ea3974 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 21 Jul 2024 10:08:39 +0200 Subject: [PATCH] add tests --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ tests/testthat/_snaps/standardize_parameters.md | 13 +++++++++++++ tests/testthat/test-standardize_parameters.R | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/_snaps/standardize_parameters.md diff --git a/DESCRIPTION b/DESCRIPTION index c5c11e856..eb54f5beb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.22.0.6 +Version: 0.22.0.7 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index d6fb7504a..6cd3ccab6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,10 @@ * Support for `svy2lme` models from package *svylme*. +## Changes + +* `standardize_parameters()` now also prettifies labels of factors. + ## Bug fixes * Fixed issue with `equivalence_test()` when ROPE range was not symmetrically diff --git a/tests/testthat/_snaps/standardize_parameters.md b/tests/testthat/_snaps/standardize_parameters.md new file mode 100644 index 000000000..52be9f09c --- /dev/null +++ b/tests/testthat/_snaps/standardize_parameters.md @@ -0,0 +1,13 @@ +# Preserve labels + + Code + print(out) + Output + # Standardization method: refit + + Parameter | Std. Coef. | 95% CI + -------------------------------------------------- + (Intercept) | -1.01 | [-1.18, -0.84] + Species [versicolor] | 1.12 | [ 0.88, 1.37] + Species [virginica] | 1.91 | [ 1.66, 2.16] + diff --git a/tests/testthat/test-standardize_parameters.R b/tests/testthat/test-standardize_parameters.R index c8ea93295..8eded4d6d 100644 --- a/tests/testthat/test-standardize_parameters.R +++ b/tests/testthat/test-standardize_parameters.R @@ -24,6 +24,12 @@ test_that("Robust post hoc", { expect_error(standardize_parameters(model, method = "basic", robust = TRUE, two_sd = TRUE), NA) }) +# Labels ------------------------------------------------------------------ +test_that("Preserve labels", { + fit <- lm(Sepal.Length ~ Species, data = iris) + out <- standardize_parameters(fit) + expect_snapshot(print(out)) +}) # model_parameters ------------------------------- test_that("standardize_parameters (model_parameters)", {