Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/testthat/test-data_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
match = "or",
return_indices = TRUE
))
x2 <- nrow(poorman::filter(efc, c172code == 1 | e16sex == 2))

Check warning on line 34 in tests/testthat/test-data_match.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_match.R,line=34,col=9,[nrow_subset_linter] Use arithmetic to count the number of rows satisfying a condition, rather than fully subsetting the data.frame and counting the resulting rows. For example, replace nrow(subset(x, is_treatment)) with sum(x$is_treatment). NB: use na.rm = TRUE if `is_treatment` has missing values.
expect_identical(x1, x2)

# "AND" works
Expand All @@ -41,7 +41,7 @@
match = "and",
return_indices = TRUE
))
x2 <- nrow(poorman::filter(efc, c172code == 1, e16sex == 2))

Check warning on line 44 in tests/testthat/test-data_match.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_match.R,line=44,col=9,[nrow_subset_linter] Use arithmetic to count the number of rows satisfying a condition, rather than fully subsetting the data.frame and counting the resulting rows. For example, replace nrow(subset(x, is_treatment)) with sum(x$is_treatment). NB: use na.rm = TRUE if `is_treatment` has missing values.
expect_identical(x1, x2)

# "NOT" works
Expand All @@ -51,7 +51,7 @@
match = "not",
return_indices = TRUE
))
x2 <- nrow(poorman::filter(efc, c172code != 1, e16sex != 2))

Check warning on line 54 in tests/testthat/test-data_match.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_match.R,line=54,col=9,[nrow_subset_linter] Use arithmetic to count the number of rows satisfying a condition, rather than fully subsetting the data.frame and counting the resulting rows. For example, replace nrow(subset(x, is_treatment)) with sum(x$is_treatment). NB: use na.rm = TRUE if `is_treatment` has missing values.
expect_identical(x1, x2)

# remove NA
Expand Down Expand Up @@ -239,7 +239,7 @@
)

foo3 <- function(data) {
var <- "mpg >= 30"

Check warning on line 242 in tests/testthat/test-data_match.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-data_match.R,line=242,col=5,[object_overwrite_linter] 'var' is an exported object from package 'stats'. Avoid re-using such symbols.
data_filter(data, var)
}
expect_identical(
Expand Down Expand Up @@ -346,12 +346,11 @@
out3 <- data_filter(iris, (Sepal.Width == 3.0) & (Species == "setosa"))
expect_identical(nrow(out3), 6L)

# styler: off
# fmt: skip
expect_error(
data_filter(iris, (Sepal.Width = 3.0) & (Species = "setosa")), # nolint
regex = "Filtering did not work"
)
# styler: on
})


Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-data_modify.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## styler: off

test_that("data_modify works", {
data(iris)
out <- data_modify(
Expand Down Expand Up @@ -1011,5 +1009,3 @@ withr::with_environment(
expect_identical(out1, out2)
})
)

## styler: on
Loading