Retrieves Japan's Gross Domestic Product (GDP) in current US dollars
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is NY.GDP.MKTP.CD.
Source
World Bank Open Data API: https://data.worldbank.org/indicator/NY.GDP.MKTP.CD
Value
A tibble with the following columns, or NULL if the API is unavailable:
indicator: Indicator name (e.g., "GDP (current US$)")country: Country name ("Japan")year: Year of the data (integer)value: GDP value in numeric formvalue_label: Formatted GDP value (e.g., "1,466,464,899,304")
Details
The function sends a GET request to the World Bank API.
If the API request fails or returns an error status code, the function returns NULL with an informative message.
Examples
# \donttest{
# Requires internet connection
result <- get_japan_gdp()
if (!is.null(result)) {
print(result)
}
#> # A tibble: 13 × 5
#> indicator country year value value_label
#> <chr> <chr> <int> <dbl> <chr>
#> 1 GDP (current US$) Japan 2022 4.26e12 4,262,463,317,797
#> 2 GDP (current US$) Japan 2021 5.04e12 5,039,148,168,861
#> 3 GDP (current US$) Japan 2020 5.05e12 5,054,068,005,376
#> 4 GDP (current US$) Japan 2019 5.12e12 5,117,993,853,017
#> 5 GDP (current US$) Japan 2018 5.04e12 5,040,880,939,325
#> 6 GDP (current US$) Japan 2017 4.93e12 4,930,837,369,151
#> 7 GDP (current US$) Japan 2016 5.00e12 5,003,677,627,544
#> 8 GDP (current US$) Japan 2015 4.44e12 4,444,930,651,964
#> 9 GDP (current US$) Japan 2014 4.90e12 4,896,994,405,353
#> 10 GDP (current US$) Japan 2013 5.21e12 5,212,328,181,166
#> 11 GDP (current US$) Japan 2012 6.27e12 6,272,362,996,105
#> 12 GDP (current US$) Japan 2011 6.23e12 6,233,147,172,341
#> 13 GDP (current US$) Japan 2010 5.76e12 5,759,071,769,013
# }
