| mean_sd | R Documentation |
This function calculates the mean standard deviation for one or more numeric variables grouped by an event identifier. It is useful for diagnosing aggregation sensitivity by assessing how much variation exists in numeric values reported across event reports concerning the same event.
mean_sd(data, group_var, variables)
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 compute standard deviations for. All specified variables must be numeric. |
For each variable and event, the function computes the standard deviation of values reported across event reports These values are then averaged across all events to produce a single score per variable. The result is a long-format dataframe that shows which numeric variables exhibit the most event report level disagreement
A tibble with two columns:
The name of each variable.
The mean standard deviation across events for that variable.
df <- data.frame(
event_id = c(1, 1, 2, 2, 3),
country = c("US", "US", "UK", "UK", "CA"),
actor1 = c("Actor A", "Actor B", "Actor B", "Actor C", "Actor D"),
deaths_best = c(10, 20, 5, 15, 10)
)
mean_sd(
df,
group_var = "event_id",
variables = c("deaths_best")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.