Learn R Programming

vote (version 2.5-2)

approval: Approval and Plurality Vote Count

Description

Count votes using the approval and plurality methods. Each voter can select candidates using 1 for a selection and 0 otherwise. In the approval method, any number of candidates can be selected by a voter, while in the plurality method only one candidate can be chosen by a voter. Thus, plurality voting is a special case of approval voting. The winner(s) in either method is/are the most-approved candidate(s). Each vote can be weighted.

Usage

approval(votes, nseats = 1, fsep = "\t", weight.column = NULL, 
    quiet = FALSE, ...)

# S3 method for vote.approval summary(object, ...)

# S3 method for vote.approval view(object, ...)

plurality(votes, nseats = 1, fsep = "\t", weight.column = NULL, quiet = FALSE, ...)

# S3 method for vote.plurality summary(object, ...)

# S3 method for vote.plurality view(object, ...)

Value

Functions approval and plurality return an object of class vote.approval and vote.plurality, respectively, both of which are lists with the following objects:

elected

Vector of names of the elected candidates in the order in which they were elected.

totals

Vector of total votes in the same order as candidates (columns) in the input data.

data

Input data with invalid votes removed. Weights are attached as an attribute called “weights”.

invalid.votes

Matrix of invalid votes that were removed from the original dataset.

Arguments

votes

Matrix or data frame of zeros and ones 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. Missing values (NA) are interpreted as zeros. The dataset can have an extra column containing a weight for each vote. Name of this column must be passed into the argument weight.column.

nseats

Number of candidates to be elected.

fsep

If votes is a file name, this argument gives the column separator in the file.

weight.column

Name of a column in the votes dataset that represent weights. If given, a weighted voting is performed.

quiet

If TRUE no output is printed.

...

Not used.

object

Object of class vote.approval or vote.plurality.

Author

Hana Sevcikova, Adrian Raftery

References

https://en.wikipedia.org/wiki/Approval_voting

https://en.wikipedia.org/wiki/Plurality_voting_method

See Also

count.votes

Examples

Run this code
# Example using the IMS Council dataset modified for approval voting
data(ims_approval)
approval(ims_approval) # Li wins

# Increase the weight of voters who did not vote for Li
weighted.approval <- cbind(ims_approval, weight = 1)
weighted.approval$weight[ims_approval$Li == 0] <- 2
approval(weighted.approval, weight.column = "weight") # now Jasper wins

# Example using the IMS Council dataset modified for plurality voting
data(ims_plurality)
pl.ims <- plurality(ims_plurality)
invalid.votes(pl.ims)

# Can we get Wang to win by increasing the weight of its votes?
weighted.plurality <- cbind(ims_plurality, weight = 1)
weighted.plurality$weight[ims_plurality$Wang == 1] <- 10
plurality(weighted.plurality, weight.column = "weight") # now Wang wins

Run the code above in your browser using DataLab