
Get Japan's Total Population from World Bank
Source:R/get_japan_population.R
get_japan_population.RdRetrieves Japan's total population for the years 2010 to 2022
using the World Bank Open Data API. The indicator used is SP.POP.TOTL.
Source
World Bank Open Data API: https://data.worldbank.org/indicator/SP.POP.TOTL
Value
A tibble with the following columns, or NULL if the API is unavailable:
indicator: Indicator name (e.g., "Population, total")country: Country name ("Japan")year: Year of the data (integer)value: Population as a numeric valuevalue_label: Formatted population with commas (e.g., "126,000,000")
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_population()
if (!is.null(result)) {
print(result)
}
#> # A tibble: 13 × 5
#> indicator country year value value_label
#> <chr> <chr> <int> <int> <chr>
#> 1 Population, total Japan 2022 125124989 125,124,989
#> 2 Population, total Japan 2021 125681593 125,681,593
#> 3 Population, total Japan 2020 126261000 126,261,000
#> 4 Population, total Japan 2019 126633000 126,633,000
#> 5 Population, total Japan 2018 126811000 126,811,000
#> 6 Population, total Japan 2017 126972000 126,972,000
#> 7 Population, total Japan 2016 127076000 127,076,000
#> 8 Population, total Japan 2015 127141000 127,141,000
#> 9 Population, total Japan 2014 127276000 127,276,000
#> 10 Population, total Japan 2013 127445000 127,445,000
#> 11 Population, total Japan 2012 127629000 127,629,000
#> 12 Population, total Japan 2011 127833000 127,833,000
#> 13 Population, total Japan 2010 128070000 128,070,000
# }