xSub (version 0.0.1)

get_xSub_multi: Get xSub files for multiple countries

Description

This function downloads and merges mutiple country files from www.x-sub.org. Syntax is similar to get_xSub().

Usage

get_xSub_multi(data_source, country_iso3 = NULL, space_unit, time_unit,
  merge_files = TRUE, out_dir = tempdir(), write_file = TRUE,
  write_format = "csv", verbose = FALSE)

Arguments

data_source

Name of data source. Character string. See info_xSub() for full list.

country_iso3

Country codes (ISO3). Character string or vector. See info_xSub() for full list. If left blank, function will download all available countries for selected data source.

space_unit

Geographic level of analysis. Character string. Can be one of "adm0" (country), "adm1" (province), "adm2" (district), "priogrid" (grid cell), "clea" (electoral constituency). See info_xSub(details=TRUE) for availability by country.

time_unit

Temporal level of analysis. Character string. Can be one of "year", "month", "week", "day". See info_xSub(details=TRUE) for availability by country.

merge_files

Logical. If merge_files=TRUE (default), function will combine individual country files into single data.frame, and write single file to disk. If merge_files=FALSE, function produces a list, and writes individual country files to disk separately.

out_dir

Path to directory where files will be saved. Character string. Default is R session<U+2019>s temporary directory, tempdir().

write_file

Logical. If write_file=TRUE, selected file will be written to disk, at location specified by out_dir.

write_format

Output file format. Character string. Can be one of "csv" (comma-separated values, default), "R" (RData format, compatible with R statistical programming language), "STATA" (dta format, compatible with Stata 14).

verbose

Logical. When verbose=TRUE, file download progress is printed to console..

See Also

info_xSub, get_xSub

Examples

Run this code
# NOT RUN {
# Check which countries are available for GED
info_xSub(data_source="GED")

# Example with two countries
# }
# NOT RUN {
my_file <- get_xSub_multi(data_source = "GED",country_iso3 = c("EGY","AGO"),
           space_unit = "adm1",time_unit = "month")
# }
# NOT RUN {
# Example with all countries (WARNING: this can take a long time to run)
# }
# NOT RUN {
my_file <- get_xSub_multi(data_source = "BeissingerProtest",country_iso3 = NULL,
           space_unit = "adm0",time_unit = "year")
# }

Run the code above in your browser using DataCamp Workspace