From f3a2591735855565d76e8a2df77b639229cbd427 Mon Sep 17 00:00:00 2001 From: billingtt Date: Mon, 30 Sep 2024 08:33:48 -0400 Subject: [PATCH] Add inter_numeric param --- R/acled_api.R | 25 ++++++++++++++----------- man/acled_api.Rd | 3 +++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/R/acled_api.R b/R/acled_api.R index 1021328..d7c4e4d 100755 --- a/R/acled_api.R +++ b/R/acled_api.R @@ -10,6 +10,7 @@ #' @param timestamp numerical or character string. Provide a date or datetime written as either a character string of yyyy-mm-dd or as a numeric Unix timestamp to access all events added or updated after that date. #' @param event_types vector of one or more event types (character). Default is NULL, which will return data for all event types. To reurn data for only specific event types, request one or more of the following options (not case sensitive): Battles, Violence against civilians, Protests, Riots, Strategic Developments, and Explosions/Remote violence. #' @param population character. Specify whether to return population estimates for each event. It accepts three options: "none" (default), "best", and "full". +#' @param inter_numeric logical. If FALSE (default), interaction code columns (inter1, inter2, and interaction) returned as strings describing the actor types/interactions. If TRUE, the values are returned as numeric values. #' @param monadic logical. If FALSE (default), returns dyadic data. If TRUE, returns monadic actor1 data. #' @param ... string. Any additional parameters that users would like to add to their API calls (e.g. interaction or ISO) #' @param acled_access logical. If TRUE (default), you have used the acled_access function and the email and key arguments are not required. @@ -67,9 +68,10 @@ acled_api <- function(email = NULL, timestamp = NULL, event_types = NULL, population = "none", - monadic = FALSE, - ..., - acled_access = TRUE, + inter_numeric = FALSE, + monadic = FALSE, + ..., + acled_access = TRUE, prompt = TRUE, log = F) { @@ -439,9 +441,11 @@ acled_api <- function(email = NULL, } } # nocov end + + # Population argument - if (population == "none") { + if(population == "none") { population_internal <- "" } else if (population == "best") { population_internal <- "&population=true" @@ -449,14 +453,12 @@ acled_api <- function(email = NULL, population_internal <- "&population=full" } - # Population argument + # Inter argument - if(population == "none") { - population_internal <- "" - } else if (population == "best") { - population_internal <- "&population=true" + if(inter_numeric == TRUE) { + inter_internal <- "&inter_num=1" } else { - population_internal <- "&population=full" + inter_internal <- "&inter_num=0" } # Loop through country bins to define each api call @@ -466,7 +468,8 @@ acled_api <- function(email = NULL, email_internal, key_internal, countries_internal[[i]], dates_internal, timestamp_internal, - event_types_internal, population_internal, ..., "&limit=0") + event_types_internal, population_internal, + inter_internal, ..., "&limit=0") } diff --git a/man/acled_api.Rd b/man/acled_api.Rd index cf25ca0..23601fc 100755 --- a/man/acled_api.Rd +++ b/man/acled_api.Rd @@ -14,6 +14,7 @@ acled_api( timestamp = NULL, event_types = NULL, population = "none", + inter_numeric = FALSE, monadic = FALSE, ..., acled_access = TRUE, @@ -40,6 +41,8 @@ acled_api( \item{population}{character. Specify whether to return population estimates for each event. It accepts three options: "none" (default), "best", and "full".} +\item{inter_numeric}{logical. If FALSE (default), interaction code columns (inter1, inter2, and interaction) returned as strings describing the actor types/interactions. If TRUE, the values are returned as numeric values.} + \item{monadic}{logical. If FALSE (default), returns dyadic data. If TRUE, returns monadic actor1 data.} \item{...}{string. Any additional parameters that users would like to add to their API calls (e.g. interaction or ISO)}