The main function of the package is called count.votes
. If no specific method is passed, it decides on the basis of the available data which method is the most appropriate. Specific methods can also be invoked explicitly.
The following voting methods are available:
stv: Single transferable vote (STV) where voters rank candidates in order. It is also known as ranked choice voting or instant runoff.
score: Range voting where each voter gives each candidate a
score within a specific range.
approval: Voters give each candidate one (approve) or zero (not approve).
plurality: Each voter chooses one candidate.
condorcet: Voters rank candidates in order. The winner is determined in pairwise comparisons.
tworound.runoff: Two-round majority system with ranked ballots. If no candidate gets the majority, there is a run-off between the top two candidates.
Output of these functions can be viewed using summary
methods, or in a browser using view
methods. The summary
methods return a data frame which can be stored in a file, see Example below. Outputs of the stv
method can be plotted in a graph. The joint and marginal distributions of ranked votes (for stv
, condorcet
and tworound.runoff
) can be visualized in an image plot.
Functions invalid.votes
and valid.votes
can be used to check the validity of ballots for the various methods. Function correct.ranking
can be used to make ballot corrections to ranked data, including ballots with equal preferences.
Example datasets are included. The ims_election
dataset contains anonymized ballots from a past Council election of the Institute of Mathematical Statistics (IMS) which uses the STV method. Modifications of this dataset are available (ims_approval
, ims_score
, ims_plurality
) as examples of data required by the various methods. The food_election
dataset taken from Wikipedia can be used to test the STV method. Similarly, methods for ranked voting can be applied to the dublin_west
dataset which contains election ballots from the 2002 election to the Dublin West constituency in Ireland.