count.votes: Count Votes

Description Usage Arguments Value Author(s) See Also Examples

View source: R/count_votes.R

Description

Count votes using one of five methods. View valid, invalid and corrected ballots.

Usage

1
2
3
4
5
6
count.votes(votes, method = c("auto", "plurality", "approval", "stv", 
    "score", "condorcet", "tworound.runoff"), fsep = "\t", ...)
	
invalid.votes(object)
valid.votes(object)
corrected.votes(object)

Arguments

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 votes is a file name, this argument gives the column separator in the file.

...

Additional arguments passed to the underlying functions, e.g. nseats, max.score etc.

object

Object returned by one of the functions plurality, approval, stv, score, condorcet, tworound.runoff.

Value

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

Author(s)

Hana Sevcikova, Bernard Silverman

See Also

stv, approval, score, condorcet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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

vote documentation built on Feb. 5, 2022, 1:08 a.m.