name_to_abbr: Get state abbreviations from state names

Description Usage Arguments Value See Also Examples

View source: R/utils.R

Description

Look up state abbreviations by state names (including District of Columbia and Puerto Rico); this function is based on grep(), and hence allows for regular expressions.

Usage

1
2
3
4
5
6
7
name_to_abbr(
  name,
  ignore.case = FALSE,
  perl = FALSE,
  fixed = FALSE,
  ties_method = c("first", "all")
)

Arguments

name

Vector of state names to look up.

ignore.case, perl, fixed

Arguments to pass to grep(), with the same defaults as in the latter function. Hence, by default, regular expressions are used; to match against a fixed string (no regular expressions), set fixed = TRUE.

ties_method

If "first", then only the first match for each name is returned. If "all", then all matches for each name are returned.

Value

A vector of state abbreviations if ties_method equals "first", and a list of state abbreviations otherwise.

See Also

abbr_to_name()

Examples

1
2
name_to_abbr("Penn")
name_to_abbr(c("Penn", "New"), ties_method = "all")

covidcast documentation built on May 4, 2021, 9:08 a.m.