get_xSub_multi: Get xSub files for multiple countries

View source: R/get_xSub_multi.R

get_xSub_multiR Documentation

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,
  sources_type = "individual",
  data_type = "spatial panel",
  country_iso3 = NULL,
  space_unit,
  time_unit,
  geo_window = "1 km",
  time_window = "1 day",
  dyad_type = "undirected",
  merge_files = TRUE,
  out_dir = getwd(),
  write_file = FALSE,
  write_format = "csv",
  verbose = FALSE
)

Arguments

data_source

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

sources_type

Type of data sources ("individual" or "multiple"). Character string.

data_type

Type of dataset ("event" or "panel"). Character string.

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.

geo_window

Geographic window (if source_type="multiple"). Could be either of "1 km" or "5 km". Character string or vector.

time_window

Time window (if source_type="multiple"). Could be either of "1 day" or "2 day". Character string or vector.

dyad_type

Time window (if source_type="multiple"). Could be either of "undirected" or "directed". Character string or vector.

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.

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

info_xSub, get_xSub

Examples

# 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 = "PITF",country_iso3 = c("ALB","ARM"),
           space_unit = "adm0",time_unit = "year")

## End(Not run)

# 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")

## End(Not run)

# Example with two countries, multiple sources, event-level
## Not run: 
my_file <- get_xSub_multi(sources_type = "multiple",data_type="event",country_iso3 = c("EGY","AGO"))

## End(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")

## End(Not run)

zhukovyuri/xSub documentation built on July 4, 2022, 6:46 p.m.