Learn R Programming

vote (version 2.2-1)

score: Score Vote Count

Description

Count votes using the score (or range) method. Voters give each candidate a score, the scores are added and the candidate(s) with the highest (or lowest) totals is/are elected.

Usage

score(votes, mcan = 1, max.score = NULL, larger.wins = TRUE, 
  fsep = "\t", quiet = FALSE, …)

# S3 method for vote.score summary(object, …)

# S3 method for vote.score view(object, …)

Arguments

votes

Matrix or data frame containing the votes which should be numbers between 0 and max.score. 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.

mcan

Number of candidates to be elected.

max.score

Maximum score allowed. It is used to remove invalid votes. If not given, the maximum value contained in the data is taken and thus, all non-negative votes are valid.

larger.wins

Logical argument indicating whether the winners are the candidates with the highest scores (default) or the lowest scores.

fsep

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

quiet

If TRUE no output is printed.

Not used.

object

Object of class vote.score.

Value

Function score returns an object of class vote.score which is a list 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.

larger.wins

Input argument of the same name.

data

Input data with invalid votes removed.

invalid.votes

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

References

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

See Also

count.votes

Examples

Run this code
# NOT RUN {
# Example using the IMS Council dataset modified for score voting
data(ims_score)
score.ims <- score(ims_score, max.score = 9)
summary(score.ims)
# }

Run the code above in your browser using DataLab