Learn R Programming

eventreport (version 0.1.1)

aggregation_diagnostics: Compute multiple aggregation diagnostics for a set of variables

Description

This convenience function runs all six diagnostic functions in the package, mean divergence, normalized divergence, mean standard deviation, mean range, share of events with disagreement, and modal confidence, and returns a combined tibble with one row per variable.

Usage

aggregation_diagnostics(data, group_var, variables)

Value

A tibble with one row per variable and columns:

variable

The name of each variable.

dscore

Mean divergence score.

dscore_normalized

Normalized divergence score.

mean_sd

Mean within-event standard deviation (numeric variables only).

mean_range

Mean within-event range (numeric variables only).

share_disagreement

Share of events with any disagreement.

modal_confidence

Average modal confidence per variable.

#' @importFrom dplyr full_join

Arguments

data

A data frame containing event report level data.

group_var

A character string naming the column that uniquely identifies events (e.g., "event_id").

variables

A character vector of column names to include in the diagnostics.

Details

The function handles mixed-type input: each diagnostic is only run on the subset of variables for which it is valid. Variables that do not apply to a particular diagnostic will have `NA` in that column.

Examples

Run this code
small_maverick_event_report %>%
  aggregation_diagnostics(
    group_var = "event_id",
    variables = c("city", "deaths_best", "actor1")
   )

Run the code above in your browser using DataLab