Learn R Programming

vote (version 1.2-1)

vote-package: Election Vote Counting

Description

Counting election votes and determining election results by different methods, including the single transferable vote (ranked choice), approval, score and plurality methods.

Arguments

Details

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 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.

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. Functions invalid.votes and valid.votes can be used to check the validity of ballots for the various methods.

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.

Examples

Run this code
# NOT RUN {
data(ims_election)
res <- count.votes(ims_election, method = "stv", mcan = 5)
summary(res)

# View invalid votes
invalid.votes(res)

# }
# NOT RUN {
# View results in a browser
view(res)

# Write election results into a csv file
s <- summary(res)
write.csv(s, "IMSstvresults.csv")
# }

Run the code above in your browser using DataLab