download_undata_table: Download data.un.org tables as csvs

View source: R/get_undata.R

download_undata_tableR Documentation

Download data.un.org tables as csvs

Description

Download data.un.org tables as csvs

Usage

download_undata_table(
  table_url,
  output_dir,
  record_limit = 1e+05,
  download_sleep = 30,
  base_url = "http://data.un.org/Data.aspx",
  downloader_url = "http://data.un.org/Handlers/DownloadHandler.ashx"
)

Arguments

table_url

[character(1)]
The full url to a specific table. If filters, columns, sort order or other options are selected, use the 'Link to this page' -> 'Update' button to update the table_url.

output_dir

[character(1)]
Directory to save separate downloaded data files.

record_limit

[numeric(1)]
Upper limit of records/rows that you can download at once.

download_sleep

[numeric(1)]
Seconds to sleep/wait between download calls.

base_url

[character(1)]
The base url of the data.un.org site. Default is 'http://data.un.org/Data.aspx'.

downloader_url

The base url of the data.un.org site download interface. Default is 'http://data.un.org/Handlers/DownloadHandler.ashx'.

Details

A list of all possible tables is shown here http://data.un.org/Explorer.aspx. Currently this function assumes one is able to filter by Year when downloading data.

The 'data.un.org' website does not allow one to download more than 100,000 records at a time. In order to account for this, we loop through groups of years that stay below the limit. This means table_url should not already include specified filters for years as this function is intended to download all years of data.

Value

[character()] file paths for each separate file downloaded.

See Also

Other get_undata: get_undata_nrecords(), get_undata_update_dates(), undata_url_to_query()

Examples

## Not run: 
table <- download_undata_table(
  table_url = "http://data.un.org/Data.aspx?d=POP&f=tableCode:7;areaCode:0&v=1",
  output_dir = tempdir()
)

## End(Not run)


ihmeuw-demographics/demUtils documentation built on Feb. 27, 2024, 1:25 p.m.