File: test-standardize_datagrid.R

package info (click to toggle)
r-cran-datawizard 1.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,300 kB
  • sloc: sh: 13; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# standardize -----------------------------------------------------
test_that("standardize.datagrid", {
  x <- insight::get_datagrid(iris, by = "Sepal.Length", range = "sd", length = 3)
  out <- standardize(x)
  expect_identical(as.numeric(out$Sepal.Length), c(-1, 0, 1), tolerance = 1e-3)
  expect_identical(as.numeric(out$Sepal.Width), c(0, 0, 0), tolerance = 1e-3)

  x <- insight::get_datagrid(iris, by = "Sepal.Length = c(-1, 0)")
  out <- unstandardize(x, select = "Sepal.Length")
  expect_identical(
    out$Sepal.Length[1:2],
    c(mean(iris$Sepal.Length) - sd(iris$Sepal.Length), mean(iris$Sepal.Length)),
    tolerance = 1e-3
  )
})