xSub (version 0.0.1)

get_xSub: Get xSub file

Description

This function downloads individual files from www.x-sub.org. Function produces a data.frame, for the user's choice of data source, country, spatial and temporal units, and (optionally) writes this data.frame to disk, in multiple formats.

Usage

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

Arguments

data_source

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

country_iso3

Country code (ISO3). See info_xSub() for full list.

country_name

Country name. See info_xSub() for full list.

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.

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. 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_multi

Examples

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

# Download ACLED data for Egypt, at country-year level
my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY",
           space_unit = "adm0",time_unit = "year")

# Download ACLED data for Egypt, at district-month level
# }
# NOT RUN {
my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY",
           space_unit = "adm2",time_unit = "month")
# }
# NOT RUN {
# With country name instead of ISO3 code
# }
# NOT RUN {
my_file <- get_xSub(data_source = "ACLED",country_name = "Egypt",
           space_unit = "adm2",time_unit = "month")
# }

Run the code above in your browser using DataLab