Learn R Programming

mregions (version 0.1.8)

mr_names_search: Search for region names

Description

Search for region names

Usage

mr_names_search(x, q = NULL, ...)

Arguments

x, q

Either a tbl_df, returned from mr_names(), or a query as a character string. If a tbl_df, you must pass a query string to q. If a query string (character) is passed to x, leave q as NULL

...

Parameters passed on to agrep()

Value

NULL if no matches found, or a data.frame, or tibble, of class tbl_df, with slots:

  • name (character) - name of the region, which is a combination of the name_first and name_second, e.g., Morocco:elevation_10m

  • title (character) - title for the region

  • name_first (character) - first part of the name, e.g., Morocco

  • name_second (character) - second part of the name, e.g., elevation_10m

Examples

Run this code
# NOT RUN {
# Get region names with mr_names() function
(res <- mr_names("MarineRegions:eez"))

# to save time, pass in the result from mr_names()
mr_names_search(res, q = "Amer")

# if you don't pass in the result from mr_names(), we have to
# call mr_names() internally, adding some time
mr_names_search(x = "iho", q = "Black")
mr_names_search(x = "iho", q = "Sea")

# more examples
mr_names_search("iho", "Sea")
(res <- mr_names("MarineRegions:iho"))
mr_names_search(res, q = "Sea")
# }

Run the code above in your browser using DataLab