File: test-pipe.R

package info (click to toggle)
r-cran-parameters 0.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,852 kB
  • sloc: sh: 16; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 868 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
skip_on_cran()
skip_if(getRversion() < "4.2.0")

test_that("print in pipe", {
  data(iris)
  out <- capture.output({
    lm(Sepal.Length ~ Petal.Length + Species, data = iris) |>
      model_parameters() |>
      print(include_reference = TRUE)
  })
  expect_identical(
    out[5],
    "Species [setosa]     |        0.00 |      |                |        |       "
  )
})


skip_if_not_installed("withr")
withr::with_options(
  list(easystats_table_width = Inf),
  test_that("print in pipe, on-the-fly factor", {
    data(mtcars)
    out <- capture.output({
      mtcars |>
        lm(mpg ~ cut(wt, c(0, 2.5, 3, 5)), data = _) |>
        model_parameters(include_reference = TRUE)
    })
    expect_identical(
      out[4],
      "cut(wt, c(0, 2.5, 3, 5)) [>0-2.5] |        0.00 |      |                 |       |       "
    )
  })
)