/usr/share/doc/r-cran-dplyr/tests/testthat/test-colwise-filter.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 22 23 24 25 26 27 28 29 30 31 | context("colwise filter")
test_that("filter_if()", {
expect_identical(nrow(filter_if(mtcars, is_integerish, all_vars(. > 1))), 0L)
expect_identical(nrow(filter_if(mtcars, is_integerish, all_vars(. > 0))), 7L)
})
test_that("filter_at()", {
sepal_large <- filter_at(iris, vars(starts_with("Sepal")), all_vars(. > 4))
expect_equal(sepal_large$Sepal.Length, c(5.7, 5.2, 5.5))
})
test_that("filter_all()", {
expect_identical(filter_all(mtcars, any_vars(. > 200))$disp, mtcars$disp[mtcars$disp > 200])
})
test_that("aborts on empty selection", {
expect_error(
filter_if(mtcars, is_character, all_vars(. > 0)),
"`.predicate` has no matching columns",
fixed = TRUE
)
})
test_that("aborts when supplied funs()", {
expect_error(
filter_all(mtcars, funs(. > 0)),
"`.vars_predicate` must be a call to `all_vars()` or `any_vars()`, not list",
fixed = TRUE
)
})
|