This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
#' @param y a vector of identifiers to check against x
|
||||
#' @param distinct logical, should duplicate values of x and y be removed before testing
|
||||
#'
|
||||
#' @return
|
||||
#' @return nothing, print a summary of match statistics to the console
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
|
||||
@@ -158,7 +158,7 @@ race_short_names <- function(x) {
|
||||
#' na_sum(x) # 15
|
||||
na_sum <- function(x) {
|
||||
stopifnot(is.numeric(x))
|
||||
message("Taking a sum with missing values equal to 0, be careful 🐲")
|
||||
message("Taking a sum with missing values equal to 0, be careful! \u1F601")
|
||||
x <- na_zero(x)
|
||||
return(sum(x))
|
||||
}
|
||||
@@ -168,6 +168,15 @@ na_sum <- function(x) {
|
||||
# It also substitutes in PR and DC for Puerto Rico and District of Columbia
|
||||
# which are not included in the lookup table of states and state abbreviations
|
||||
# that comes with R.
|
||||
#' Title
|
||||
#'
|
||||
#' @param x a vector of state names
|
||||
## #' @importFrom datasets state.abb state.name
|
||||
#' @return state abbreviations matching state naems provided in X
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' postcode_lookup("Montana")
|
||||
postcode_lookup <- function(x) {
|
||||
modify_name <- c(state.name, "District of Columbia", "Puerto Rico")
|
||||
modify_abb <- c(state.abb, "DC", "PR")
|
||||
@@ -181,6 +190,7 @@ postcode_lookup <- function(x) {
|
||||
#' @param x, the character value to match
|
||||
#' @param y, a vector of multiple character values to look for a match in
|
||||
#' @param n, an integer, how many matches to return
|
||||
#' @importFrom stringdist stringsim
|
||||
#'
|
||||
#' @return an integer giving the position of the table with the most characters
|
||||
trunc_match <- function(x, y, n) {
|
||||
@@ -224,8 +234,8 @@ outersect <- function(x, y, ...) {
|
||||
#' @param stabbr a two letter abbreviation for a US state
|
||||
#'
|
||||
#' @return FIPS codes that match the abbreviation
|
||||
#' @import tidycensus
|
||||
#' @export
|
||||
#' @importFrom tidycensus fips_codes
|
||||
#'
|
||||
#' @examples
|
||||
#' get_fips("MT")
|
||||
@@ -243,8 +253,8 @@ get_fips <- function(stabbr) {
|
||||
#' @param fips a character value that captures the FIPS code with leading 0
|
||||
#'
|
||||
#' @return a character value, length 2, with the state abbreviation
|
||||
#' @import tidycensus
|
||||
#' @export
|
||||
#' @importFrom tidycensus fips_codes
|
||||
#'
|
||||
#' @examples
|
||||
#' get_stabbr("06")
|
||||
@@ -339,7 +349,7 @@ z_univariate <- function(unit_prop, global_prop, unit_denom) {
|
||||
#' @details The count in the name means that this function enforces a floor of
|
||||
#' 0 on values, so values perturbed to have less than 0 will be capped at 0.
|
||||
#'
|
||||
#' @return
|
||||
#' @return a numeric vector
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
@@ -361,6 +371,7 @@ perturb_count <- function(x, fac = 3) {
|
||||
#' @return rounded values
|
||||
#' @export
|
||||
#' @details Credit to Jens von Bergmann for this algo https://github.com/mountainMath/dotdensity/blob/master/R/dot-density.R
|
||||
#' @importFrom stats runif
|
||||
#'
|
||||
#' @examples
|
||||
#' random_round(1.93)
|
||||
|
||||
Reference in New Issue
Block a user