star: STAR voting

View source: R/voting.R

starR Documentation

STAR voting

Description

Score Then Automatic Runoff (STAR) voting. See https://en.wikipedia.org/wiki/STAR_voting for more detail on properties.

Usage

star(vote_df, verbose = TRUE)

Arguments

vote_df

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

verbose

print score and automatic runoff tables

Value

invisibly returns the automatic runoff table

Examples

sim_vote = function(n_cand) {
  # Simulate one voter's scores from 0-5.
  # Higher candidates more likely to get higher scores.
  # Last candidate will be most likely to win.

  floor(6*rbeta(n_cand, 1:n_cand, 1))
}

n_voter = 100
n_cand = 4

vote_df = data.frame(voter_id  = rep(1:n_voter, each = n_cand),
                     candidate = rep(1:n_cand, times = n_voter),
                     score = as.vector(replicate(n_voter, sim_vote(n_cand))))

star(vote_df)

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