knitr::opts_chunk$set(echo = TRUE)

defaultW <- getOption("warn") 

options(warn = -1) 

ACLED is a ‘living dataset’ -- the dataset is added to frequently and existing data can be updated.

The dataset changes in three ways:

For users with an ACLED dataset saved locally on their computer, ACLED suggests that you regularly check for deleted or updated events to ensure your dataset is up to date. In this section you will learn how to keep your dataset updated by using the acledR package.

Keeping track of updates - acled_update()

As detailed in ACLED’s guide about updating your dataset, in some cases events are updated or deleted, necessitating an update of your downloaded dataset.

Unlike for deleted events, there is no separate API endpoint to check for updated events. When events are updated, their timestamp changes to reflect the timing of the most recent change. This means, that you can find the updated events by using acledR::acled_api() while providing the most recent timestamp (i.e. max({your ACLED dataset}$timestamp))) in your local dataset as the timestamp argument of the function. If there is an event with a more recent timestamp but the same event_id_cnty as an event in your downloaded dataset, then that event has been modified. Hence, you can remove the duplicated event with the smaller timestamp value.

To simplify this process, acledR includes a function which makes the update for you by following the steps previously explained:

acled_update(
  df,
  start_date = min(df$event_date),
  end_date = max(df$event_date),
  additional_countries = "current countries",
  regions = NULL,
  event_types = NULL,
  acled_access = TRUE,
  email = NULL,
  key = NULL,
  deleted = TRUE,
  prompts = TRUE)

The function has the following arguments:

Examples

In this section you can learn to use acled_update to keep your datasets updated.

Load your downloaded dataset:

library(acledR)
library(lubridate)
library(dplyr)
acled_access(email = "your_email", key = "your_key") #  This is an example, you will need to input your credentials.

argen_dummy_acled_file <- acledR::acled_old_dummy # Here is our old personal ACLED dataset
acled_access(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY")) #  This is an example, you will need to input your credentials.

argen_dummy_acled_file <- acledR::acled_old_dummy # Here is our old personal ACLED dataset

When was the last time you downloaded or updated your dataset?

latest_timestamp_unix <- max(argen_dummy_acled_file$timestamp)

latest_timestamp <- as_datetime(latest_timestamp_unix) 

The dataset has not been updated since r as_date(latest_timestamp), so you may want a more updated version. To do so, you can use acled_update(). Note that the inter_numeric parameter is set to TRUE because the original data -- argen_dummy_acled_file -- has variables specified as numeric rather than strings. If you are only interested in updating events that are already in your dataset, you can ignore the start_date and end_date arguments. If you also wish to remove deleted events from your dataset you can set deleted=TRUE.

new_argen_dataset <- acled_update(argen_dummy_acled_file, 
                                  additional_countries = "Argentina", 
                                  acled_access = TRUE, 
                                  inter_numeric = TRUE, 
                                  prompts = FALSE) 

Now your dataset captures modified and newly created events.

options(warn = defaultW)


billingtt/acledR documentation built on March 5, 2025, 4:40 p.m.