Title: | Cross-National Data on Sub-National Violence |
---|---|
Description: | Tools to download and merge data files on sub-national conflict, violence and protests from <http://www.x-sub.org>. |
Authors: | Yuri Zhukov [aut, cre], Christian Davenport [aut], Nadiya Kostyuk [aut] |
Maintainer: | Yuri Zhukov <[email protected]> |
License: | GPL-3 |
Version: | 3.0.2 |
Built: | 2024-11-25 03:07:42 UTC |
Source: | https://github.com/zhukovyuri/xsub |
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.
get_xSub( data_source, sources_type = "individual", data_type = "spatial panel", country_iso3 = NULL, country_name = NULL, space_unit, time_unit, geo_window = "1 km", time_window = "1 day", dyad_type = "undirected", out_dir = getwd(), write_file = TRUE, write_format = "csv", verbose = FALSE )
get_xSub( data_source, sources_type = "individual", data_type = "spatial panel", country_iso3 = NULL, country_name = NULL, space_unit, time_unit, geo_window = "1 km", time_window = "1 day", dyad_type = "undirected", out_dir = getwd(), write_file = TRUE, write_format = "csv", verbose = FALSE )
data_source |
Name of data source. See |
sources_type |
Type of data sources ("individual" or "multiple"). Character string. |
data_type |
Type of dataset ("event" or "panel"). Character string. |
country_iso3 |
Country code (ISO3). See |
country_name |
Country name. See |
space_unit |
Geographic level of analysis. Character string. Can be one of |
time_unit |
Temporal level of analysis. Character string. Can be one of |
geo_window |
Geographic window (if source_type="multiple"). Could be either of "1 km" (default) or "5 km". Character string or vector. |
time_window |
Time window (if source_type="multiple"). Could be either of "1 day" (default) or "2 day". Character string or vector. |
dyad_type |
Time window (if source_type="multiple"). Could be either of "undirected" (default) or "directed". Character string or vector. |
out_dir |
Path to directory where files will be saved. |
write_file |
Logical. If |
write_format |
Output file format. Can be one of |
verbose |
Logical. When |
# Check which countries are available for ACLED info_xSub(data_source="ACLED") # Download ACLED data for Egypt, at country-year level ## Not run: my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY", space_unit = "adm0",time_unit = "year") ## End(Not run) # 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") ## End(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") ## End(Not run) ## Not run: # Download ACLED data for Egypt, event level my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY", data_type = "event") ## End(Not run) ## Not run: # Download multiple source data for Egypt, at province-month level my_file <- get_xSub(sources_type = "multiple",country_iso3 = "EGY", space_unit = "adm1",time_unit = "month", geo_window = "1 km", time_window = "1 day", dyad_type = "undirected") ## End(Not run)
# Check which countries are available for ACLED info_xSub(data_source="ACLED") # Download ACLED data for Egypt, at country-year level ## Not run: my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY", space_unit = "adm0",time_unit = "year") ## End(Not run) # 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") ## End(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") ## End(Not run) ## Not run: # Download ACLED data for Egypt, event level my_file <- get_xSub(data_source = "ACLED",country_iso3 = "EGY", data_type = "event") ## End(Not run) ## Not run: # Download multiple source data for Egypt, at province-month level my_file <- get_xSub(sources_type = "multiple",country_iso3 = "EGY", space_unit = "adm1",time_unit = "month", geo_window = "1 km", time_window = "1 day", dyad_type = "undirected") ## End(Not run)
This function downloads and merges mutiple country files from www.x-sub.org
. Syntax is similar to get_xSub()
.
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 )
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 )
data_source |
Name of data source. Character string. See |
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 |
space_unit |
Geographic level of analysis. Character string. Can be one of |
time_unit |
Temporal level of analysis. Character string. Can be one of |
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 |
out_dir |
Path to directory where files will be saved. Character string. |
write_file |
Logical. If |
write_format |
Output file format. Character string. Can be one of |
verbose |
Logical. When |
# 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)
# 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)
This function reports the availability of files on the www.x-sub.org
server, and corresponding country codes and units of analysis. For additional info, see www.x-sub.org/about/what-is-xsub
.
info_xSub( details = FALSE, sources_type = "individual", data_type = "panel", data_source = NULL, country_iso3 = NULL, country_name = NULL, geo_window = NULL, time_window = NULL, dyad_type = NULL )
info_xSub( details = FALSE, sources_type = "individual", data_type = "panel", data_source = NULL, country_iso3 = NULL, country_name = NULL, geo_window = NULL, time_window = NULL, dyad_type = NULL )
details |
Logical. If |
sources_type |
Type of data sources ("individual" or "multiple"). Character string. |
data_type |
Type of dataset ("event" or "panel"). Character string. |
data_source |
Subset results by data sources. Character string or vector. |
country_iso3 |
Subset results by country codes (ISO3). Character string or vector. |
country_name |
Subset results by country name. Character string or vector. |
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. |
# General info on data sources and countries info_xSub() # Available files for Pakistan info_xSub(country_name = "Pakistan") # Detailed info for Pakistan info_xSub(details=TRUE,country_name = "Pakistan") # Available files for SCAD data source info_xSub(data_source = "SCAD") # Available files for SCAD data source, event-level info_xSub(data_source = "SCAD", data_type = "event") # Multiple data sources, directed dyads info_xSub(sources_type = "multiple", dyad_type = "directed") # Multiple data sources, directed dyads, Russia info_xSub(sources_type = "multiple", dyad_type = "directed", country_name = "Russia")
# General info on data sources and countries info_xSub() # Available files for Pakistan info_xSub(country_name = "Pakistan") # Detailed info for Pakistan info_xSub(details=TRUE,country_name = "Pakistan") # Available files for SCAD data source info_xSub(data_source = "SCAD") # Available files for SCAD data source, event-level info_xSub(data_source = "SCAD", data_type = "event") # Multiple data sources, directed dyads info_xSub(sources_type = "multiple", dyad_type = "directed") # Multiple data sources, directed dyads, Russia info_xSub(sources_type = "multiple", dyad_type = "directed", country_name = "Russia")
A list of data sources and countries available for download. Used by info_xSub()
xSub_census_individual_raw
xSub_census_individual_raw
A list with 4 elements:
Countries organized by data_source
. List object, where each sub-entry is also a list, containing entries for data_source
,country_iso3
,country_name
.
Data sources organized by country. List of data.frames, where each row is a country, with columns for country_iso3
,country_name
,data_sources
.
Detailed information on data sources, countries and spatial levels of analysis. data.frame, where each row is a source-country combination, with columns for data_source
,country_iso3
,country_name
,units
.
Vector of all country ISO3 codes. Used by get_xSub_multi
.
A list of data sources, countries and levels of analysis available for download. Used by info_xSub()
xSub_census_individual_spatial
xSub_census_individual_spatial
A list with 6 elements:
Countries organized by data_source
. List object, where each sub-entry is also a list, containing entries for data_source
,country_iso3
,country_name
.
Data sources organized by country. List of data.frames, where each row is a country, with columns for country_iso3
,country_name
,data_sources
.
Detailed information on data sources, countries and spatial levels of analysis. data.frame, where each row is a source-country combination, with columns for data_source
,country_iso3
,country_name
,space_units
,time_units
.
Detailed information on data sources, countries, spatial and temporal levels of analysis. data.frame, where each row is a source-country-spatial unit combination, with columns for data_source
,country_iso3
,country_name
,space_unit
,time_units
.
File census. data.frame, where each row is a single file, with columns for file_name
,data_source
,country_iso3
,country_name
,space_unit
,time_unit
.
Vector of all country ISO3 codes. Used by get_xSub_multi
.
A list of data sources, countries and levels of analysis available for download. Used by info_xSub()
xSub_census_multiple_raw
xSub_census_multiple_raw
A list with 4 elements:
Countries organized by data_source
. List object, where each sub-entry is also a list, containing entries for data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
.
Data sources organized by country. List of data.frames, where each row is a country, with columns for country_iso3
,country_name
,geo_window
,time_window
,dyad_type
,data_sources
.
Detailed information on data sources, countries and spatial levels of analysis. data.frame, where each row is a source-country combination, with columns for data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
,units
.
Vector of all country ISO3 codes. Used by get_xSub_multi
.
A list of data sources, countries and levels of analysis available for download. Used by info_xSub()
xSub_census_multiple_spatial
xSub_census_multiple_spatial
A list with 6 elements:
Countries organized by data_source
. List object, where each sub-entry is also a list, containing entries for data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
.
Data sources organized by country. List of data.frames, where each row is a country, with columns for country_iso3
,country_name
,geo_window
,time_window
,dyad_type
,data_sources
.
Detailed information on data sources, countries and spatial levels of analysis. data.frame, where each row is a source-country combination, with columns for data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
,space_units
,time_units
.
Detailed information on data sources, countries, spatial and temporal levels of analysis. data.frame, where each row is a source-country-spatial unit combination, with columns for data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
,space_unit
,time_units
.
File census. data.frame, where each row is a single file, with columns for file_name
,data_source
,geo_window
,time_window
,dyad_type
,country_iso3
,country_name
,space_unit
,time_unit
.
Vector of all country ISO3 codes. Used by get_xSub_multi
.