tworound.runoff | R Documentation |
Count votes using the two-round voting method with ranked ballots. If no candidate reaches the majority, the top two candidates go into a run-off.
tworound.runoff(votes, fsep = '\t', seed = NULL, quiet = FALSE, ...)
## S3 method for class 'vote.tworound.runoff'
summary(object, ...)
## S3 method for class 'vote.tworound.runoff'
view(object, ...)
## S3 method for class 'vote.tworound.runoff'
image(x, ...)
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. See below for more details. |
fsep |
If |
seed |
Integer. Seed of the random number generator (RNG). Only used if there are ties either between candidates to enter the run-off, or between the two run-off contenders. If set to |
quiet |
If |
object , x |
Object of class |
... |
Additional arguments passed to the underlying functions. For the |
First, the number of first preferences is counted. If there is a candidate with more than 50%, that candidate gets elected. Otherwise, there is a runoff between the top two candidates.
The input data votes
is structured the same way as for the stv
method: Row i
contains the preferences of voter i
numbered 1, 2, \dots, r, 0,0,0,0
, in some order. Equal preferences are not allowed. The columns correspond to the candidates. The dimnames of the columns are the names of the candidates; if these are not supplied then the candidates are lettered A, B, C, .... If the dataset contains missing values (NA
), they are replaced by zeros.
The image
function visualizes the joint distribution of two preferences (if all.pref=FALSE
) given by xpref
and ypref
, as well as the marginal distribution of all preferences (if all.pref=TRUE
). The joint distribution can be shown as proportions (if proportion=TRUE
) or raw vote counts (if proportion=FALSE
).
Function tworound.runoff
returns an object of class vote.tworound.runoff
which is a list with the following objects:
elected |
The elected candidate. |
totals |
Vector of total votes in the same order as candidates (columns) in the input data. |
totals2r |
Vector of total votes from the run-off (second round). |
coin.toss.winner |
|
coin.toss.runoff |
|
data |
Input data (possibly corrected) with invalid votes removed. |
invalid.votes |
Matrix of invalid votes that were removed from the original dataset. |
Hana Sevcikova, Salvatore Barbaro
Sen A. (2017). Collective Choice and Social Welfare. Harvard University Press, Cambridge, Massachusetts, Chapter 10*3 (p. 243ff).
https://en.wikipedia.org/wiki/Two-round_system
data(ims_election)
trr <- tworound.runoff(ims_election)
summary(trr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.