fix: address review round 3 for #7

This commit is contained in:
2026-07-05 00:56:30 -04:00
parent 0d523c83de
commit 4ea7333835
2 changed files with 8 additions and 6 deletions
+4 -2
View File
@@ -111,7 +111,9 @@ nvals <- function(x){
#' simpleCap(my_string)
simpleCap <- function(x) {
stopifnot(class(x) == "character")
s <- strsplit(x, " ")[[1]]
paste(toupper(substring(s, 1,1)), substring(s, 2),
sapply(x, function(word) {
s <- strsplit(word, " ")[[1]]
paste(toupper(substring(s, 1, 1)), substring(s, 2),
sep = "", collapse = " ")
})
}
+3 -3
View File
@@ -31,7 +31,7 @@ safe_max <- function(x) {
#' pretty_per(0.2, ndigit = 1)
#' pretty_per(c(0.2, 0.332423, 0.4, 0.342342), ndigit = 2)
pretty_per <- function(x, ndigit = 1) {
if (any(x >= 100) & !all(is.na(x))) {
if (any(x >= 100) && !all(is.na(x))) {
message("Values over 100 found, did you mean to use proportions?")
}
x <- format(round(x, digits = ndigit + 2) * 100, nsmall = ndigit)
@@ -283,7 +283,7 @@ get_stabbr <- function(fips) {
fips_codes <- fips_codes[!duplicated(fips_codes),]
if (length(fips) != 1) {
out <- rep(NA, length(fips))
for (i in length(fips)) {
for (i in seq_along(fips)) {
out[i] <- fips_codes[fips_codes$state_code == fips, 1]
}
@@ -375,7 +375,7 @@ random_round <- function(x) {
add = rep(as.integer(0),length(r))
add[r>test] <- as.integer(1)
value = v + add
ifelse(is.na(value) | value<0, 0, value)
value <- ifelse(is.na(value) | value < 0, 0, value)
return(value)
}