Type: | Package |
Title: | Wrapper for 'TCdata360' and 'Govdata360' API |
Version: | 1.0.9 |
Description: | Makes it easy to engage with the Application Program Interface (API) of the 'TCdata360' and 'Govdata360' platforms at https://tcdata360.worldbank.org/ and https://govdata360.worldbank.org/, respectively. These application program interfaces provide access to over 5000 trade, competitiveness, and governance indicator data, metadata, and related information from sources both inside and outside the World Bank Group. Package functions include easier download of data sets, metadata, and related information, as well as searching based on user-inputted query. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
URL: | https://github.com/mrpsonglao/data360r |
Date: | 2022-06-09 |
Imports: | data.table, reshape2, jsonlite, utils |
RoxygenNote: | 7.1.0 |
NeedsCompilation: | no |
Packaged: | 2022-06-09 19:14:54 UTC; wb578064 |
Author: | Ramin Aliyev [cre], Ma. Regina Paz Onglao-Drilon [aut], World Bank Group [cph] |
Maintainer: | Ramin Aliyev <tcdata360@worldbank.org> |
Repository: | CRAN |
Date/Publication: | 2022-06-10 09:10:06 UTC |
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')
Get TC/Govdata360 metadata from API
Description
Downloads the requested metadata by using the TCdata360 API at https://tcdata360.worldbank.org/docs or Govdata360 API at https://govdata360.worldbank.org/docs. The function generates a wide dataframe.
Usage
get_metadata360(site = "tc", metadata_type = "countries")
Arguments
site |
string pertaining to the data360 site to download data from. Possible choices: 'tc' for TCdata360, 'gov' for Govdata360 |
metadata_type |
string pertaining to the metadata to be downloaded. Possible choices: 'countries' == Lists metadata for all countries and regions. 'indicators' == Lists metadata for all indicators. Does not return actual data. 'datasets' == Lists metadata for all datasets. |
Details
Hint: Want to get other data? Helpful functions include:
See
search_360
to get search TC/Govdata360 indicators, countries, categories, and dataset lists.See
get_data360
to get actual indicator/dataset/country-level data.See
get_resources360
to get additional resource information.
Value
Data frame (wide) containing requested metadata
Examples
## Since all functions download data through API, these are wrapped with
## the "donttest" function as advised by CRAN
#get all indicator metadata in Govdata360
df_indicators <- get_metadata360(site="gov", metadata_type = "indicators")
#get all country metadata in TCdata360
df_countries <- get_metadata360(metadata_type = 'countries')
#get all dataset metadata in TCdata360
df_datasets <- get_metadata360(metadata_type = 'datasets')
Get TC/Govdata360 resource information from API
Description
Downloads the requested resource information by using the TCdata360 API at https://tcdata360.worldbank.org/docs or Govdata360 API at https://govdata360.worldbank.org/docs. The function generates a wide dataframe containing resource information.
Usage
get_resources360(site = "tc", resource_type = "nav")
Arguments
site |
string pertaining to the data360 site to download data from. Possible choices: 'tc' for TCdata360, 'gov' for Govdata360 |
resource_type |
string pertaining to the metadata to be downloaded. Possible choices: 'related' == Find WBG content related to certain topics and countries. Note that this endpoint calls a number of external API so may take around 10s to return on the initial call, however after this the response will be cached. 'toolkits' == Find WBG toolkits related to certain topics and subtopics. 'nav' == List root categories in navigational hierarchy. |
Details
Hint: Want to get other data? Helpful functions include:
See
search_360
to get search TC/Govdata360 indicators, countries, categories, and dataset lists.See
get_data360
to get actual indicator/dataset/country-level data.See
get_metadata360
to get indicator/dataset/country-level metadata.
Value
Data frame (wide) containing requested resource information
Examples
## Since all functions download data through API, these are wrapped with
## the "donttest" function as advised by CRAN
#get all root-level categories in TCdata360
df_nav <- get_resources360()
#get all toolkits from Govdata360
df_toolkits <- get_resources360(site='gov', resource_type = 'toolkits')
Search TC/Govdata360 indicators, countries, categories, and dataset lists
Description
Searches using the TCdata360 API at https://tcdata360.worldbank.org/docs or Govdata360 API at https://govdata360.worldbank.org/docs. The function generates a wide dataframe containing the top search results related to the query.
Usage
search_360(
search_string = "World Bank",
site = "tc",
search_type = NULL,
limit_results = NULL
)
Arguments
search_string |
string to query in TC/Govdata360 |
site |
string pertaining to the data360 site to download data from. Possible choices: 'tc' for TCdata360, 'gov' for Govdata360 |
search_type |
NULL (optional). Character vector of search types to include. Possible values include: 'indicator', 'category', 'country' Leaving this NULL will return all possible search results. |
limit_results |
NULL (optional). Number pertaining to the number of top results to be kept. |
Details
Hint: Want to use your search results to call data? Helpful functions include:
See
get_data360
to get actual indicator/dataset/country-level data.See
get_metadata360
to get indicator/dataset/country-level metadata.See
get_resources360
to get additional resource information.
Value
List containing top search results
Examples
## Since all functions download data through API, these are wrapped with
## the "donttest" function as advised by CRAN
#search a country's code in TCdata360
search_360('Philippines', search_type = 'country')
#search for top 10 relevant indicator codes in TCdata360
search_360('GDP', search_type = 'indicator', limit_results = 10)
#search for top 10 indicators of a database in TCdata360
search_360('World Development Indicators', search_type = 'indicator',
limit_results = 10)
#search for top 10 indicators of a data provider in TCdata360
search_360('WEF', search_type = 'indicator', limit_results = 10)
#search for top 10 relevant categories in Govdata360
search_360('Governance', site='gov', search_type = 'category', limit_results = 10)