Learn R Programming

wbstats (version 1.0.4)

wb_search: Search indicator information available through the World Bank API

Description

This function allows finds indicators that match a search term and returns a data frame of matching results

Usage

wb_search(
  pattern,
  fields = c("indicator_id", "indicator", "indicator_desc"),
  extra = FALSE,
  cache,
  ignore.case = TRUE,
  ...
)

Arguments

pattern

Character string or regular expression to be matched

fields

Character vector of column names through which to search

extra

if FALSE, only the indicator ID and short name are returned, if TRUE, all columns of the cache parameter's indicators data frame are returned. Default is FALSE

cache

List of data frames returned from wb_cache(). If omitted, wb_cachelist is used

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching. Default is TRUE

...

Any additional grep() agruments you which to pass

Value

a tibble with indicators that match the search pattern.

Examples

Run this code
# NOT RUN {
d <- wb_search(pattern = "education")
# }
# NOT RUN {
# }
# NOT RUN {
d <- wb_search(pattern = "Food and Agriculture Organization", fields = "source_org")
# }
# NOT RUN {
# with regular expression operators
# 'poverty' OR 'unemployment' OR 'employment'
# }
# NOT RUN {
d <- wb_search(pattern = "poverty|unemployment|employment")
# }
# NOT RUN {
# pass any other grep argument along as well
# everything without 'education'
# }
# NOT RUN {
d <- wb_search(pattern = "education", invert = TRUE)
# }
# NOT RUN {
# contains "gdp" AND "trade"
# }
# NOT RUN {
d <- wb_search("^(?=.*gdp)(?=.*trade).*", perl = TRUE)
# }
# NOT RUN {
# contains "gdp" and NOT "trade"
# }
# NOT RUN {
d <- wb_search("^(?=.*gdp)(?!.*trade).*", perl = TRUE)
# }

Run the code above in your browser using DataLab