tests/testthat/test-attr-safe.R

test_that("Recoding is attribute safe", {
  x <- sample(0:1, 100, replace = TRUE)
  attr(x, "test") <- "test"

  y <- recode_vec(
    x,
    coding(code("Yes", "YES"), code("No", "NO")),
    from = coding(code("Yes", 1), code("No", 0))
  )

  expect_identical(
    attr(y, "test"),
    attr(x, "test")
  )
})

Try the rcoder package in your browser

Any scripts or data that you put into this service are public.

rcoder documentation built on Oct. 6, 2023, 9:06 a.m.