Skip to content

Commit

Permalink
Drop == FALSE conditions and replace with (!)
Browse files Browse the repository at this point in the history
  • Loading branch information
krauwe committed Feb 19, 2024
1 parent 21ad775 commit abf45e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/classify_nuts.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ classify_nuts <-
cli_abort("Input {.arg data} must be a data frame or tibble, not {.obj_type_friendly {data}}.")
if (!is.character(nuts_code))
cli_abort("Input {.arg nuts_code} must be provided as a string, not {.obj_type_friendly {nuts_code}}.")
if (nuts_code %in% colnames(data) == FALSE)
if (!(nuts_code %in% colnames(data)))
cli_abort("Input {.arg nuts_code} not found in the provided data frame.")
if (!ties %in% c("most_recent", "oldest"))
cli_abort("Input {.arg ties} must be 'most_recent' or 'oldest'.")
Expand All @@ -82,7 +82,7 @@ classify_nuts <-
rename(from_code = !!sym(nuts_code))

# Simple NUTS code check
if (any(str_detect(data$from_code, "^[A-Za-z]{2}[A-Za-z0-9]{1,3}$") == FALSE))
if (!(any(str_detect(data$from_code, "^[A-Za-z]{2}[A-Za-z0-9]{1,3}$"))))
cli_abort(
c(
"Variable {.var {nuts_code}} contains invalid NUTS codes.",
Expand All @@ -93,7 +93,7 @@ classify_nuts <-

# Grouping vars, country identified by default
if (!is.null(group_vars)) {
if (any(group_vars %in% colnames(data) == FALSE)) {
if (!(any(group_vars %in% colnames(data)))) {
cli_abort("Input {.arg group_vars} not found in the provided data frame.")
}
group_vars <- c("country", group_vars)
Expand Down
2 changes: 1 addition & 1 deletion R/convert_nuts_level.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ convert_nuts_level <-
if (is.null(variables))
cli_abort("Input {.arg variables} cannot be NULL.")

if (any(names(variables) %in% colnames(data[["data"]])) == FALSE)
if (!(any(names(variables) %in% colnames(data[["data"]]))))
cli_abort("Input {.arg variables} not found in the provided data frame.")

if (any(!(unlist(variables) %in% c("absolute", "relative"))))
Expand Down
2 changes: 1 addition & 1 deletion R/convert_nuts_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ convert_nuts_version <-
if (is.null(variables))
cli_abort("Input {.arg variables} cannot be NULL.")

if (any(names(variables) %in% colnames(data[["data"]])) == FALSE)
if (!(any(names(variables) %in% colnames(data[["data"]]))))
cli_abort("Input {.arg variables} not found in the provided data frame.")

if (any(!(unlist(variables) %in% c("absolute", "relative"))))
Expand Down

0 comments on commit abf45e4

Please sign in to comment.