Description Usage Arguments Details Value See Also Examples
This function allows for the creation of dictionary objects that are
either optional or required elements of other postmastr
functions. Once created,
dictionary objects should not be modified as the formatting of dictionary elements provides
other postmastr
functions with predictable inputs. The "state"
,
"directional"
, and "suffix"
dictionaries are based on tables that are also
exported so that they can be previewed and tested.
Street dictionaries cannot be created using pm_dictionary
. Users who wish to standardize
street names in their data should create a dictionary appendix with pm_append
and use
that as the primary dictionary for functions that accept street dictionaries. The same is true
for house suffix dictionaries.
1 | pm_dictionary(type, append, filter, case = c("title", "lower", "upper"), locale = "us")
|
type |
A string indicating the grammatical address element the dictionary
should represent. Current options are |
append |
An optional dictionary appendix object created with |
filter |
An optional character scalar or vector with output elements that should
be retained. Filter inputs are based on the expected output: states should be specified
with their two-letter abbrevation (i.e. |
case |
An optional character scalar or vector containing one or more of three valid
options - |
locale |
A string indicating the country these data represent; the only
current option is |
The city dictionary functionality is powered by the get_acs function from the tidycensus package. This requires a Census Bureau API key, which can be obtained at http://api.census.gov/data/key_signup.html. Once you have a key, the census_api_key function from tidycensus should be used to set-up the key before proceeding with the creation of any dictionary objects for cities.
A postmastr
dictionary object, which will always include an input column
of possible terms for the given grammatical address element. All dictionary objects
except for city dictionaries will also contain an output column with the
preferred output for each input. For American addresses, these outputs follow United States
Postal Service guidelines.
pm_append
, dic_us_dir
, dic_us_states
,
dic_us_suffix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # build state dictionary, title case only
pm_dictionary(type = "state", filter = "MO", case = "title", locale = "us")
# build state dictionary, title and upper case
pm_dictionary(type = "state", filter = "MO", case = c("title", "upper"), locale = "us")
# build New England state dictionary, all cases
pm_dictionary(type = "state", filter = c("CT", "MA", "ME", "NH", "RI", "VT"),
case = c("title", "upper", "lower"), locale = "us")
# add custom abbreviation for Massachusetts
## create dictionary appendix
ma <- pm_append(type = "state", input = "Mass", output = "MA", locale = "us")
## add dictionary appendix to dictionary
pm_dictionary(type = "state", filter = c("CT", "MA", "ME", "NH", "RI", "VT"),
append = ma, case = "title", locale = "us")
# build Missouri city dictionary
## Not run:
# tidycensus::census_api_key("YOUR API KEY GOES HERE")
pm_dictionary(type = "city", filter = "MO", case = "upper", locale = "us")
## End(Not run)
# build directional dictionary
pm_dictionary(type = "directional", filter = c("N", "S", "E", "W"), locale = "us")
# build suffix dictionary
pm_dictionary(type = "suffix", filter = c("Ave", "Rd"), locale = "us")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.