You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
680 B

make_params <- function(params, by, ok="") {
by <- stringi::stri_trans_tolower(by)
by <- stringi::stri_replace_all_regex(by, "[[:space:]]", "")
by <- strsplit(by, "")[[1]]
by <- purrr::keep(by, `%in%`, ok)
by <- sort(unique(by))
params <- c(params, setNames(as.list(rep("*", length(by))), by))
}
.clean_cols <- function(x) {
x <- stringi::stri_replace_all_fixed(x, ",", "")
if (any(grepl("%", x))) {
as.numeric(stringi::stri_replace_all_fixed(x, "%", ""))/100
} else if (any(grepl("\\$", x))) {
as.numeric(stringi::stri_replace_all_fixed(x, "$", ""))
} else {
x
}
}
clean_cols <- function(x) {
suppressWarnings(
.clean_cols(x)
)
}