Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inter_numeric param #29

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions R/acled_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -439,24 +441,24 @@ 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"
} else {
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
Expand All @@ -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")
}


Expand Down
3 changes: 3 additions & 0 deletions man/acled_api.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading