/usr/share/doc/r-cran-dplyr/tests/testthat/test-copying.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("Copying")
test_that("coercion doesn't copy vars", {
mtcars2 <- tbl_df(mtcars)
mtcars3 <- as.data.frame(mtcars2)
expect_equal(location(mtcars2)$vars, location(mtcars)$vars)
expect_equal(location(mtcars3)$vars, location(mtcars)$vars)
})
test_that("grouping and ungrouping doesn't copy vars", {
mtcars2 <- group_by(mtcars, cyl)
mtcars3 <- ungroup(mtcars2)
expect_equal(location(mtcars2)$vars, location(mtcars)$vars)
expect_equal(location(mtcars3)$vars, location(mtcars)$vars)
})
test_that("mutate doesn't copy vars", {
mtcars2 <- tbl_df(mtcars)
mtcars3 <- mutate(mtcars2, cyl2 = cyl * 2)
expect_equal(location(mtcars3)$vars[1:11], location(mtcars2)$vars)
})
test_that("select doesn't copy vars", {
mtcars2 <- tbl_df(mtcars)
mtcars3 <- select(mtcars2, carb:mpg)
expect_equal(location(mtcars3)$vars[11:1], location(mtcars2)$vars)
})
|