Fix ggplot2 imports and polish utility functions for publication
R-CMD-check / R CMD check (push) Failing after 4m35s
R-CMD-check / R CMD check (push) Failing after 4m35s
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 vapply() to capitalise each vector element independently. Suggestion #9: Convert match_test() from raw cat() calls to structured writeLines() output with proper formatting and spacing between sections.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#' @return a numeric column of data
|
||||
#' @export
|
||||
countCleanr <- function(x){
|
||||
if(class(x) == "character"){
|
||||
if ("character" %in% class(x)) {
|
||||
x[x == "None not reported"] <- "0"
|
||||
x[x == "Not applicable"] <- NA
|
||||
x <- as.numeric(x)
|
||||
@@ -110,8 +110,12 @@ nvals <- function(x){
|
||||
#' my_string <- c("Happy school", "Easy school", "cool School", "big school")
|
||||
#' simpleCap(my_string)
|
||||
simpleCap <- function(x) {
|
||||
stopifnot(class(x) == "character")
|
||||
s <- strsplit(x, " ")[[1]]
|
||||
paste(toupper(substring(s, 1,1)), substring(s, 2),
|
||||
sep = "", collapse = " ")
|
||||
stopifnot("character" %in% class(x))
|
||||
|
||||
# Vectorised over elements of x — each element is capitalised independently.
|
||||
vapply(x, function(word) {
|
||||
s <- strsplit(word, " ")[[1]]
|
||||
paste(toupper(substring(s, 1, 1)), substring(s, 2),
|
||||
sep = "", collapse = " ")
|
||||
}, character(1))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user