get_location_std | R Documentation |
get a standardized name for a vector of locations. This will identify most likely matched to the inputted names used a variety of tools and methods. This should be used when the data likely have locations that are not only countries (i.e., some sub-countries like England or Dubai)
get_location_std(location, ref_locations = NULL)
location |
vector of location names |
ref_locations |
vector of reference locations to match to. If left NULL, will search location names included in package |
# Get Standardized Name for Location #' @name get_location_std #' @title get_location_std #' @description get a standardized name for a vector of locations. This will identify most likely matched #' to the inputted names used a variety of tools and methods. This should be used when the data likely have #' locations that are not only countries (i.e., some sub-countries like England or Dubai) #' @param location vector of location names #' @return vector of names for each location. These can then be used to identify other characteristics of the location #' @export get_location_std <- function(location)
location <- standardize_location_strings(location)
# just check the unique countries to speed it up location_all <- location location <- unique(location) location_indexes <- match(location_all, location)
# # First try to match the country using get_iso and get_country_name_std loc_stds <- get_country_name_std(location)
# If not completely successful, try using "match_locs_level2" function if (sum(is.na(loc_stds)) != 0) locs_need_match <- is.na(loc_stds) match_attempt2 <- as.character(lapply( X = location[locs_need_match], FUN = function(X) as.character(match_locs_level2(X)) )) # fill in new matches loc_stds[locs_need_match] <- match_attempt2 return(loc_stds[location_indexes])
## JK : Turn this into an actual examples block probably # # Example # data('test_mixed_names',package='globaltoolboxlite') # get_iso(country=test_mixed_names)
vector of names for each location. These can then be used to identify other characteristics of the location
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.