ranked_pairs: Ranked pairs voting

View source: R/voting.R

ranked_pairsR Documentation

Ranked pairs voting

Description

This function performs ranked pairs voting.

Usage

ranked_pairs(vote_df, plot = TRUE)

Arguments

vote_df

a data frame with three columns: voter_id, candidate, and vote_rank

plot

if TRUE, plot the pair graph

Examples

# Simulate data. Candidate 3 should be ranked first most often.
vote_df = data.frame(voter_id = rep(1:100, each = 4),
                     candidate = rep(1:4, times = 100),
                     vote_rank = replicate(100,
                                           order(sample(1:4,
                                                        replace = FALSE,
                                                        prob = c(.1, .45, .5, .1))),
                                           simplify = FALSE) |> unlist())
ranked_pairs(vote_df)


andrewGhazi/geryon documentation built on April 14, 2025, 3:51 p.m.