Often different sources of geographical data will use different names for the same region. These utilities make it easier to merge data from different sources by converting names to standardized forms.
standardName(
x,
standard,
ignore.case = TRUE,
returnAlternatives = FALSE,
quiet = FALSE
)standardCountry(
x,
ignore.case = TRUE,
returnAlternatives = FALSE,
quiet = FALSE
)
standardState(x, ignore.case = TRUE, returnAlternatives = FALSE, quiet = FALSE)
A vector with the region names to standardize
a named vector providing the map from non-standard names (names of vector) to standard names (values of vector)
a logical indicating whether case should be ignored when matching.
a logical indicating whether all alternatives should be returned in addition to the standard name.
a logical indicating whether warnings should be suppressed
This is the most general standardizing function.
In addition to x
, this function requires another argument:
standard
- a named vector in which each name is a particular
spelling of the region name in question and the corresponding value
is the standardized version of that region name
This function will standardize the country
names in x
to the standard ISO_a3 country code format. If
returnAlternatives
is set to TRUE
, this function will also
return the the named vector used to standardize the country names
This function will standardize the US state
names in x
to the standard two-letter abbreviations. If
returnAlternatives
is set to TRUE
, this function will also
return the the named vector used to standardize the state names
In all three cases, any names not found in standard
will be left unaltered. Unless supressed, a warning message will
indicate the number of such cases, if there are any.