ranked_pairs | R Documentation |
This function performs ranked pairs voting.
ranked_pairs(vote_df, plot = TRUE)
vote_df |
a data frame with three columns: voter_id, candidate, and vote_rank |
plot |
if TRUE, plot the pair graph |
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.