subset_elections: Subset an ei_summary to fewer races

View source: R/ei_methods.R

subset_electionsR Documentation

Subset an ei_summary to fewer races

Description

Extracts a subset of races from an existing "ei_summary" object without reloading or recomputing from raw data. Vote counts remain exactly as in the original object because the universe is unchanged.

Usage

subset_elections(x, elections)

## S3 method for class 'ei_summary'
x[elections]

Arguments

x

An "ei_summary" object.

elections

Character vector of race codes to retain. Must be a subset of x$meta$elections.

Details

The [ operator is also available as a shorthand: x[elections] is equivalent to subset_elections(x, elections).

Value

A new "ei_summary" object restricted to elections.

Examples


obj3 <- ei_summary(c("PRE", "USS", "HOS3"))

# Equivalent ways to extract a 2-race subset
obj2 <- subset_elections(obj3, c("PRE", "USS"))
obj2 <- obj3[c("PRE", "USS")]

obj1 <- obj3["PRE"]   # single race: no joint array



eiballots documentation built on Sept. 26, 2026, 5:06 p.m.