count.votes | R Documentation |
Count votes using one of five methods. View valid, invalid and corrected ballots.
count.votes(votes, method = c("auto", "plurality", "approval", "stv",
"score", "condorcet", "tworound.runoff"), fsep = "\t", ...)
invalid.votes(object)
valid.votes(object)
corrected.votes(object)
votes |
Matrix or data frame containing the votes. Rows correspond to the votes, columns correspond to the candidates. If it is a character string it is interpreted as a file name from which the votes are to be read. |
method |
Voting method to use. If “auto”, the input data is passed through a checker for each of the methods and the one with the largest number of valid votes is used. In case of the same number of valid votes, it goes by their ordering in the function definition. |
fsep |
If |
... |
Additional arguments passed to the underlying functions, e.g. |
object |
Object returned by one of the functions |
Depending which method is used, count.votes
returns an object of class vote.plurality
, vote.approval
, vote.stv
, vote.score
, vote.condorcet
, or vote.tworound.runoff
.
Functions valid.votes
and invalid.votes
return a subset of the input data with valid records and invalid records, respectively.
Function corrected.votes
can be used when votes are automatically corrected (as in stv
and condorcet
). It returns a list with the uncorrected votes (item original
), the corrected votes (item new
), and its indices within the original votes dataset (item index
).
Hana Sevcikova, Bernard Silverman
stv
, approval
, score
, condorcet
# Example using the IMS Council dataset modified for score voting
data(ims_score)
# should recognize that it is a dataset with score voting data
count.votes(ims_score, max.score = 9, larger.wins = FALSE)
# All records with score larger than 8 are excluded
res <- count.votes(ims_score, method = "score", max.score = 8)
head(invalid.votes(res))
summary(res)
# For a corrected.votes() example see ?stv
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.