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")
  )
})
nyuglobalties/rcoder documentation built on Oct. 10, 2023, 7:13 p.m.