Skip to contents

List all indicators supported by the World Bank API.

Usage

wb_indicator(indicator = NULL, lang = "en", source = NULL)

Arguments

indicator

(NULL | character(1))
Indicator to query. Default NULL. If NULL, all indicators are returned.

lang

(character(1))
Language to query. Default "en".

source

(NULL | integer(1))
ID of the source to query, as listed by wb_source(). Default NULL, which uses the API default.

Value

A data.frame() with the available indicators. Since an indicator can have several topics, topic_id and topic_value hold all of them separated by ;, which never occurs within a value, or NA if there are none. Use strsplit(x, ";") to split them, or a pattern such as "(^|;)Health(;|$)" to match a single topic exactly. The columns are:

  • id: The indicator ID.

  • name: The indicator name.

  • unit: The indicator unit.

  • source_id: The source ID.

  • source_value: The source value.

  • source_note: The source note.

  • source_organization: The source organization.

  • topic_id: The topic IDs, as listed by wb_topic().

  • topic_value: The topic names, in the same order as topic_id.

Examples

# \donttest{
wb_indicator("NY.GDP.MKTP.CD")
#>               id              name unit source_id                 source_value
#> 1 NY.GDP.MKTP.CD GDP (current US$) <NA>         2 World Development Indicators
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 source_note
#> 1 Gross domestic product is the total income earned through the production of goods and services in an economic territory during an accounting period. It can be measured in three different ways: using either the expenditure approach, the income approach, or the production approach. This indicator is expressed in current prices, meaning no adjustment has been made to account for price changes over time. This indicator is expressed in United States dollars.
#>                                                                                                                                                                                                     source_organization
#> 1 Country official statistics, National Statistical Organizations and/or Central Banks;\nNational Accounts data files, Organisation for Economic Co-operation and Development (OECD);\nStaff estimates, World Bank (WB)
#>   topic_id      topic_value
#> 1        3 Economy & Growth

# an indicator can have several topics, separated by `;`
ind <- wb_indicator("SE.ENR.PRSC.FM.ZS")
ind[c("topic_id", "topic_value")]
#>       topic_id
#> 1 2;19;4;17;15
#>                                                            topic_value
#> 1 Aid Effectiveness;Climate Change;Education;Gender;Social Development
strsplit(ind$topic_value, ";")
#> [[1]]
#> [1] "Aid Effectiveness"  "Climate Change"     "Education"         
#> [4] "Gender"             "Social Development"
#> 
# }