/usr/share/doc/r-cran-dplyr/tests/testthat/test-na-if.R is in r-cran-dplyr 0.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | context("na_if")
test_that("error for bad y length", {
expect_error(
na_if(1:3, 1:2),
"`y` must be length 3 (same as `x`) or one, not 2",
fixed = TRUE
)
expect_error(
na_if(1, 1:2),
"`y` must be length 1 (same as `x`), not 2",
fixed = TRUE
)
})
test_that("scalar y replaces all matching x", {
x <- c(0, 1, 0)
expect_equal(na_if(x, 0), c(NA, 1, NA))
expect_equal(na_if(x, 1), c(0, NA, 0))
})
|