R-CMD-check / R CMD check (push) Successful in 4m17s
Blocking issue #1: Replace all ggplot2::function() calls with bare references in R/colors.R, R/logo.R, R/theme.R. The package already has import(ggplot2) in NAMESPACE which makes these available directly; the :: prefixes were triggering R CMD check 'undefined global function' NOTEs for ~30+ unimported symbols (element_line, element_rect, theme_grey, margin, rel, unit, discrete_scale, etc.). Suggestion #6: Replace class(x) == "character" with "character" %in% class(x) in R/db.R (countCleanr and simpleCap). The == pattern breaks on S3 objects with multiple class attributes. Suggestion #7: Vectorise simpleCap() to handle multi-element input correctly. Previously strsplit(x, ' ')[[1]] only processed the first element; now uses unname(vapply()) to capitalise each vector element independently while preserving the original scalar behaviour (no names attribute on output). Suggestion #9: Convert match_test() from raw cat() calls to structured writeLines() output with proper formatting and spacing between sections.
53 lines
1.3 KiB
R
53 lines
1.3 KiB
R
# Join utilities
|
|
|
|
#' Test the join between two sets of identifiers
|
|
#'
|
|
#' @param x A vector of identifiers to check against `y`.
|
|
#' @param y A vector of identifiers to look for a match in.
|
|
#' @param distinct Logical. Should duplicate values of `x` and `y` be removed
|
|
#' before testing? Default is `TRUE`.
|
|
#'
|
|
#' @return Invisibly returns `NULL`; prints a formatted summary of match
|
|
#' statistics to the console via [writeLines()].
|
|
#' @export
|
|
#'
|
|
#' @examples
|
|
#' x <- LETTERS
|
|
#' y <- c(letters, LETTERS)
|
|
#' match_test(x, y)
|
|
match_test <- function(x, y, distinct = TRUE) {
|
|
if (distinct) {
|
|
x <- unique(x)
|
|
y <- unique(y)
|
|
}
|
|
|
|
# TODO: DO not report 100% if there is even 1 mismatch
|
|
|
|
xiny <- sum(x %in% y)
|
|
total_x <- length(x)
|
|
pct_x <- round(100 * xiny / total_x, 2)
|
|
|
|
yinx <- sum(y %in% x)
|
|
total_y <- length(y)
|
|
pct_y <- round(100 * yinx / total_y, 2)
|
|
|
|
header <- if (distinct) "Distinct Matches" else "All Values"
|
|
|
|
lines <- c(
|
|
paste0("**** ", header, " ****"),
|
|
"",
|
|
"X in Y",
|
|
sprintf("Of the %d X values, %d (%s%%) were matched.",
|
|
total_x, xiny, format(pct_x, nsmall = 2)),
|
|
strrep("*", 40),
|
|
"",
|
|
"Y in X",
|
|
sprintf("Of the %d Y values, %d (%s%%) were matched.",
|
|
total_y, yinx, format(pct_y, nsmall = 2)),
|
|
strrep("*", 38)
|
|
)
|
|
|
|
writeLines(lines)
|
|
invisible(NULL)
|
|
}
|