fix: address review round 3 for #7
This commit is contained in:
@@ -111,7 +111,9 @@ nvals <- function(x){
|
|||||||
#' simpleCap(my_string)
|
#' simpleCap(my_string)
|
||||||
simpleCap <- function(x) {
|
simpleCap <- function(x) {
|
||||||
stopifnot(class(x) == "character")
|
stopifnot(class(x) == "character")
|
||||||
s <- strsplit(x, " ")[[1]]
|
sapply(x, function(word) {
|
||||||
paste(toupper(substring(s, 1,1)), substring(s, 2),
|
s <- strsplit(word, " ")[[1]]
|
||||||
sep = "", collapse = " ")
|
paste(toupper(substring(s, 1, 1)), substring(s, 2),
|
||||||
|
sep = "", collapse = " ")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ safe_max <- function(x) {
|
|||||||
#' pretty_per(0.2, ndigit = 1)
|
#' pretty_per(0.2, ndigit = 1)
|
||||||
#' pretty_per(c(0.2, 0.332423, 0.4, 0.342342), ndigit = 2)
|
#' pretty_per(c(0.2, 0.332423, 0.4, 0.342342), ndigit = 2)
|
||||||
pretty_per <- function(x, ndigit = 1) {
|
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?")
|
message("Values over 100 found, did you mean to use proportions?")
|
||||||
}
|
}
|
||||||
x <- format(round(x, digits = ndigit + 2) * 100, nsmall = ndigit)
|
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),]
|
fips_codes <- fips_codes[!duplicated(fips_codes),]
|
||||||
if (length(fips) != 1) {
|
if (length(fips) != 1) {
|
||||||
out <- rep(NA, length(fips))
|
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]
|
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 = rep(as.integer(0),length(r))
|
||||||
add[r>test] <- as.integer(1)
|
add[r>test] <- as.integer(1)
|
||||||
value = v + add
|
value = v + add
|
||||||
ifelse(is.na(value) | value<0, 0, value)
|
value <- ifelse(is.na(value) | value < 0, 0, value)
|
||||||
return(value)
|
return(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user