Skip to content

Commit

Permalink
switch TRUE and FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 10, 2024
1 parent 3a9b8a6 commit 640557c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/row_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ row_count <- function(data,
select = NULL,
exclude = NULL,
count = NULL,
allow_coercion = FALSE,
allow_coercion = TRUE,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE) {
Expand Down Expand Up @@ -90,10 +90,10 @@ row_count <- function(data,
rowSums(is.na(data))
} else {
# comparisons in R using == coerce values into a atomic vector, i.e.
# 2 == "2" is TRUE. If `allow_coercion = TRUE`, we only want 2 == 2 or
# 2 == "2" is TRUE. If `allow_coercion = FALSE`, we only want 2 == 2 or
# "2" == "2". to achieve this, we simply compute the comparison on numeric
# or non-numeric columns only
if (isTRUE(allow_coercion)) {
if (isFALSE(allow_coercion)) {
numeric_columns <- vapply(data, is.numeric, TRUE)
if (is.numeric(count)) {
data <- data[numeric_columns]
Expand Down
2 changes: 1 addition & 1 deletion man/row_count.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-row_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test_that("row_count, allow_coercion match", {
c4 = c(2, 3, 7, Inf),
stringsAsFactors = FALSE
)
expect_identical(row_count(d_mn, count = 2, allow_coercion = FALSE), c(1, 2, 0, 0))
expect_identical(row_count(d_mn, count = 2, allow_coercion = TRUE), c(1, 0, 0, 0))
expect_identical(row_count(d_mn, count = "2", allow_coercion = TRUE), c(0, 2, 0, 0))
expect_identical(row_count(d_mn, count = 2, allow_coercion = TRUE), c(1, 2, 0, 0))
expect_identical(row_count(d_mn, count = 2, allow_coercion = FALSE), c(1, 0, 0, 0))
expect_identical(row_count(d_mn, count = "2", allow_coercion = FALSE), c(0, 2, 0, 0))
})

0 comments on commit 640557c

Please sign in to comment.