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 vote.tworound.runoff
summary(object, …)
# S3 method for vote.tworound.runoff
view(object, …)
# S3 method for vote.tworound.runoff
image(x, …)
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.
If votes
is a file name, this argument gives the column separator in the file.
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 NULL
, the RNG is not initialized.
If TRUE
no output is printed.
Object of class vote.tworound.runoff
.
Additional arguments passed to the underlying functions. For the image
function, see arguments for image.vote.stv
, especially xpref
, ypref
, all.pref
and proportion
.
Function tworound.runoff
returns an object of class vote.tworound.runoff
which is a list with the following objects:
The elected candidate.
Vector of total votes in the same order as candidates (columns) in the input data.
Vector of total votes from the run-off (second round).
TRUE
if the winner was sampled between candidates with the same score, otherwise FALSE
.
TRUE
if the run-off contenders were sampled from candidates with the same score. Otherwise it is FALSE
.
Input data (possibly corrected) with invalid votes removed.
Matrix of invalid votes that were removed from the original dataset.
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
).
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
# NOT RUN {
data(ims_election)
trr <- tworound.runoff(ims_election)
summary(trr)
# }
Run the code above in your browser using DataLab