diff --git a/.Rbuildignore b/.Rbuildignore index 8d87092..19b8291 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -20,3 +20,4 @@ src/rust/uncomment.sh ^CRAN-SUBMISSION$ ^.*\.Rproj$ ^\.Rproj\.user$ +.lintr \ No newline at end of file diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..6a48818 --- /dev/null +++ b/.lintr @@ -0,0 +1,7 @@ +linters: linters_with_defaults( + line_length_linter = NULL, + indentation_linter = NULL, + commas_linter = NULL, + infix_spaces_linter = NULL + ) # see vignette("lintr") +encoding: "UTF-8" diff --git a/R/em_link.R b/R/em_link.R index 4f93a1e..3718038 100644 --- a/R/em_link.R +++ b/R/em_link.R @@ -63,7 +63,7 @@ #' @export em_link <- function(X, g, tol = 10^-6, max_iter = 10^3) { stopifnot( - "There can be no NA's in X (but you can add NA as its own agreement level)" = !any(is.na(X)) + "There can be no NA's in X (but you can add NA as its own agreement level)" = !anyNA(X) ) stopifnot( diff --git a/R/euclidean_join_core.R b/R/euclidean_join_core.R index 88af076..3cc45f9 100644 --- a/R/euclidean_join_core.R +++ b/R/euclidean_join_core.R @@ -20,7 +20,6 @@ multi_by_validate <- function(a, b, by) { by_a <- by by_b <- by } - stopifnot(by_a %in% names(a)) stopifnot(by_b %in% names(b)) } @@ -37,10 +36,10 @@ euclidean_join_core <- function(a, b, by = NULL, n_bands = 30, band_width = 10, by <- multi_by_validate(a, b, by) by_a <- by[[1]] by_b <- by[[2]] - stopifnot("There should be no NA's in by_a[1]" = !any(is.na(dplyr::pull(a, by_a[1])))) - stopifnot("There should be no NA's in by_a[2]" = !any(is.na(dplyr::pull(a, by_a[2])))) - stopifnot("There should be no NA's in by_b[1]" = !any(is.na(dplyr::pull(b, by_b[1])))) - stopifnot("There should be no NA's in by_b[2]" = !any(is.na(dplyr::pull(b, by_b[2])))) + stopifnot("There should be no NA's in by_a[1]" = !anyNA(a[[by_a[1]]])) + stopifnot("There should be no NA's in by_a[2]" = !anyNA(a[[by_a[2]]])) + stopifnot("There should be no NA's in by_b[1]" = !anyNA(b[[by_b[1]]])) + stopifnot("There should be no NA's in by_b[2]" = !anyNA(b[[by_b[2]]])) thresh_prob <- euclidean_probability(threshold, n_bands, band_width, r) if (thresh_prob < .95) { diff --git a/R/jaccard_join_core.R b/R/jaccard_join_core.R index 5f6345c..50a2357 100644 --- a/R/jaccard_join_core.R +++ b/R/jaccard_join_core.R @@ -59,20 +59,17 @@ jaccard_join <- function(a, b, mode, by, salt_by, n_gram_width, n_bands, ") have only a ", round(thresh_prob * 100), "% chance of being compared.\n", "Please consider changing `n_bands` and `band_width`." ) - warning(str) } - - by <- simple_by_validate(a, b, by) by_a <- by[[1]] by_b <- by[[2]] stopifnot("'by' vectors must have length 1" = length(by_a) == 1) stopifnot("'by' vectors must have length 1" = length(by_b) == 1) - stopifnot("There should be no NA's in by_a" = !any(is.na(dplyr::pull(a, by_a)))) - stopifnot("There should be no NA's in by_b" = !any(is.na(dplyr::pull(b, by_b)))) + stopifnot("There should be no NA's in by_a" = !anyNA(a[[by_a]])) + stopifnot("There should be no NA's in by_b" = !anyNA(b[[by_b]])) salt_by_a <- NULL salt_by_b <- NULL @@ -82,9 +79,9 @@ jaccard_join <- function(a, b, mode, by, salt_by, n_gram_width, n_bands, salt_by_a <- salt_by[[1]] salt_by_b <- salt_by[[2]] stopifnot("There should be no NA's in the blocking variables" = ! - any(is.na(dplyr::select(a, dplyr::all_of(salt_by_a))))) + anyNA(a[, salt_by_a, drop = FALSE])) stopifnot("There should be no NA's in the blocking variables" = ! - any(is.na(dplyr::select(b, dplyr::all_of(salt_by_b))))) + anyNA(b[, salt_by_b, drop = FALSE])) } # Clean strings that are matched on