get_data360 {data360r} | R Documentation |
Get TC/Govdata360 data from API
Description
Downloads the requested data by using the TCdata360 API at https://tcdata360.worldbank.org/docs or Govdata360 API at https://govdata360.worldbank.org/docs. The function generates a data frame (wide or long, depending on user input).
Usage
get_data360(
site = "tc",
indicator_id = NULL,
dataset_id = NULL,
country_iso3 = NULL,
timeframes = NULL,
output_type = "wide"
)
Arguments
site |
string pertaining to the data360 site to download data from. Possible choices: 'tc' for TCdata360, 'gov' for Govdata360 |
indicator_id |
NULL (optional); Vector of indicators codes.
Should be left NULL if |
dataset_id |
NULL (optional); Character vector of Dataset IDs for all indicator data is to be downloaded.
Should be left NULL if |
country_iso3 |
defaults to c('USA', 'PNG', 'PHL') (optional); Vector of countries (ISO-3 3-letter character codes, e.g. 'PNG', 'USA', 'PHL') for which the data is needed. Leaving this NULL pulls data for every available country. |
timeframes |
NULL (optional); Vector of years to restrict results data to.
Leaving this NULL gets all available timeframes.
Important note: |
output_type |
string pertaining to the output type. Possible choices include: 'wide' == one row contains multi-year observations 'long' == one row refers to one year only. |
Details
Hint: Don't know what codes to write as inputs for this function? Helpful functions include:
See
search_360
to get search TC/Govdata360 indicators, countries, categories, and dataset lists.See
get_metadata360
to get indicator/dataset/country-level metadata.See
get_resources360
to get additional resource information.
Value
Data frame containing requested data
Examples
## Since all functions download data through API, these are wrapped with
## the "donttest" function as advised by CRAN
#get data for dataset ID 51 in TCdata360
df <- get_data360(dataset_id = 51)
#get data for countries USA, PHL in Govdata360
df2 <- get_data360(site = 'gov', country_iso3 = c('USA', 'PHL'))
#get data for indicator IDs 944, 972 in TCdata360
df3 <- get_data360(indicator_id = c(944, 972))
#get data for indicator IDs 944, 972 in 2011-2013 in long format in TCdata360
df4 <- get_data360(indicator_id = c(944, 972), timeframes = c(2011, 2012),
output_type = 'long')