star | R Documentation |
Score Then Automatic Runoff (STAR) voting. See https://en.wikipedia.org/wiki/STAR_voting for more detail on properties.
star(vote_df, verbose = TRUE)
vote_df |
a data frame with three columns: voter_id, candidate, and vote_rank |
verbose |
print score and automatic runoff tables |
invisibly returns the automatic runoff table
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.