Description Usage Arguments Value Examples
View source: R/plurality_method.R
Although with plurality method each voter is required to mention
only one candidate, a ballot with more than one candidate and
different scores is also valid. For a score matrix, the function will
check the position j which has the lowest score (in a vote
object,
the lower, the better) in the ith row. Duplicated values may or may
not be a problem. For instance, c(2, 3, 3)
is valid, for the
lowest value is 2 and it is in the 1st position. However,
c(2, 2, 3)
is a problem, for the 1st and 2nd positions
all have the lowest value 2. If this problem exists, the winner
returned by this function will be NULL.
1 | plurality_method(x, allow_dup = TRUE, min_valid = 1)
|
x |
an object of class |
allow_dup |
whether ballots with duplicated score values are taken into account. Default is TRUE. |
min_valid |
default is 1. If the number of valid entries of a ballot is less than this value, the ballot will not be used. |
a list object.
(1) call
the function call.
(2) method
the counting method.
(3) candidate
candidate names.
(4) candidate_num
number of candidate.
(5) ballot_num
number of ballots in x.
(6) valid_ballot_num
number of ballots that are
used to compute the result.
(7) winner
the winners, may be one, more than one or NULL.
(8) absolute
whether the winner is of absolute majority.
(9) other_info
a list with 2 elements, the 1st is the
frequencies of candidates mentioned as 1st choice; the second element is
the percentage. If winner is NULL, these two are NULL.
1 2 3 4 5 6 7 8 9 10 | raw <- rbind(
c(1, 2, 5, 3, 3), c(1, 2, 5, 3, 4), c(1, 2, 5, 3, 4),
c(NA, NA, NA, NA, NA), c(NA, 3, 5, 1, 2),
c(NA, NA, NA, 2, 3), c(NA, NA, 1, 2, 3),
c(NA, NA, NA, NA, 2), c(NA, NA, NA, 2, 2),
c(NA, NA, 1, 1, 2), c(1, 1, 5, 5, NA)
)
vote <- create_vote(raw, xtype = 1)
y <- plurality_method(vote, allow_dup = FALSE)
y <- plurality_method(vote, allow_dup=FALSE, min_valid = 3)
|
MATCHING NAMES AND SCORES
COUNTING NA AND DUP VALUES
MAKING CONDORCET TABLE
COLLECTING RESULT
DONE
SELECTING
COLLECTING RESULT
DONE
SELECTING
COLLECTING RESULT
DONE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.