R/f_state.R

Defines functions f_state

Documented in f_state

#' Format State Names as Abbreviations
#'
#' Formats a state name as the abbreviated form.
#'
#' @param x A vector of states.
#' @param \ldots ignored.
#' @return Returns a string of abbreviated states.
#' @export
#' @rdname f_state
#' @examples
#' f_state(c('Texas', 'New York', NA, 'New Jersey', 'Washington', 'Europe'))
f_state <- function(x, ...){

    names(nms)[match(as.character(x), nms)]

}

nms <- datasets::state.name
names(nms) <- datasets::state.abb


#' @export
#' @include utils.R
#' @rdname f_state
ff_state <- functionize(f_state)

Try the numform package in your browser

Any scripts or data that you put into this service are public.

numform documentation built on Oct. 10, 2021, 1:10 a.m.