Skip to content

Commit

Permalink
added reference to The R Journal article; cran warning fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hanase committed Dec 10, 2023
1 parent 2aca64b commit 365b0c9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
2.4-1 (12/09/2023)
2.4-3 (12/09/2023)
-----
Added a feature into stv of imputing ranks due to for example a conflict of interests
(stv() argument impute.missing, function impute.ranking())

Fixed bug in stv related to reserved seats (thanks to Merlise Clyde)

CITATION added.

2.3-2 (2/4/2022)
-----
Fixed a bug in stv() related to equal ranking and non-overlapping votes.
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: vote
Type: Package
Title: Election Vote Counting
Version: 2.4-2
Version: 2.4-3
Date: 2023-12-09
Author: Hana Sevcikova, Bernard Silverman, Adrian Raftery
Maintainer: Hana Sevcikova<[email protected]>
Description: Counting election votes and determining election results by different methods, including
the single transferable vote or ranked choice, approval, score, plurality, condorcet and two-round runoff methods (Raftery et al. (2021) <arXiv:2102.05801>).
the single transferable vote or ranked choice, approval, score, plurality, condorcet and two-round runoff methods (Raftery et al., 2021 <doi:10.32614/RJ-2021-086>).
Depends: R (>= 3.5.0)
Imports: formattable, knitr, data.table, fields
Suggests: ggplot2
Expand Down
4 changes: 2 additions & 2 deletions R/two_round_runoff.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tworound.runoff <- function(votes, fsep = '\t', seed = NULL, quiet = FALSE, ...)
nvotes <- nrow(x)

# first round
res <- sum.votes(x == 1)
res <- .sum.votes(x == 1)
winners <- res/nvotes > 0.5
resoff <- NULL
coin.toss.winner <- coin.toss.runoff <- seed.set <- FALSE
Expand Down Expand Up @@ -43,7 +43,7 @@ tworound.runoff <- function(votes, fsep = '\t', seed = NULL, quiet = FALSE, ...)
xroff <- t(apply(xroff, 1, do.rank)) # shift ranking
colnames(xroff) <- cnames[best]
rownames(xroff) <- rownames(x)
resoff <- sum.votes(xroff == 1)
resoff <- .sum.votes(xroff == 1)
res.elect <- resoff
} else {
res.elect <- res
Expand Down
8 changes: 4 additions & 4 deletions R/vote_by_sum.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ approval <- function(votes, nseats = 1, fsep='\t', quiet = FALSE, ...) {
votes <- prepare.votes(votes, fsep=fsep)
x <- check.votes(votes, "approval", quiet = quiet)
nseats <- check.nseats(nseats, ncol(x), ...)
res <- sum.votes(x)
res <- .sum.votes(x)
elected <- names(rev(sort(res))[1:nseats])
result <- structure(list(elected=elected, totals=res, data=x,
invalid.votes=votes[setdiff(rownames(votes), rownames(x)),, drop = FALSE]),
Expand All @@ -15,7 +15,7 @@ plurality <- function(votes, nseats=1, fsep='\t', quiet = FALSE, ...) {
votes <- prepare.votes(votes, fsep=fsep)
x <- check.votes(votes, "plurality", quiet = quiet)
nseats <- check.nseats(nseats, ncol(x), ...)
res <- sum.votes(x)
res <- .sum.votes(x)
elected <- names(rev(sort(res))[1:nseats])
result <- structure(list(elected=elected, totals=res, data=x,
invalid.votes=votes[setdiff(rownames(votes), rownames(x)),, drop = FALSE]),
Expand All @@ -32,7 +32,7 @@ score <- function(votes, nseats=1, max.score=NULL, larger.wins=TRUE, fsep='\t',
}
x <- check.votes(votes, "score", max.score, quiet = quiet)
nseats <- check.nseats(nseats, ncol(x), ...)
res <- sum.votes(x)
res <- .sum.votes(x)
elected <- names(sort(res, decreasing=larger.wins)[1:nseats])
result <- structure(list(elected=elected, totals=res, larger.wins=larger.wins,
data=x, invalid.votes=votes[setdiff(rownames(votes), rownames(x)),, drop = FALSE]),
Expand All @@ -41,7 +41,7 @@ score <- function(votes, nseats=1, max.score=NULL, larger.wins=TRUE, fsep='\t',
invisible(result)
}

sum.votes <- function(votes) {
.sum.votes <- function(votes) {
vtot <- apply(votes, 2, sum)
return (vtot)
}
Expand Down
26 changes: 26 additions & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
bibentry(bibtype = "Article",
title = "{The vote Package: Single Transferable Vote and Other Electoral Systems in R}",
author = c(person(given = c("Adrian", "E."),
family = "Raftery",
email = "[email protected]"),
person(given = "Hana",
family = "\\v{S}ev\\v{c}{\\'\\i}kov\\'{a}"),
person(given = c("Bernard", "W."),
family = "Silverman",
email = "[email protected]")
),
journal = "{The R Journal}",
year = "2021",
volume = "13",
number = "2",
pages = "673--696",
doi = "10.32614/RJ-2021-086",

header = "To cite vote in publications use:",
textVersion =
paste("Raftery, A.E., Sevcikova, H. and Silverman, B.W. (2021).",
"The vote Package: Single Transferable Vote and Other Electoral Systems in R.",
"The R Journal, 13(2), 673-696.",
"doi:10.32614/RJ-2021-086")
)

2 changes: 1 addition & 1 deletion man/stv.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The \code{correct.ranking} (\code{impute.ranking}) function returns a matrix of
}

\references{
Raftery, A.E., Sevcikova, H. and Silverman, B.W. (2021). The vote Package: Single Transferable Vote and Other Electoral Systems in R. \href{https://arxiv.org/abs/2102.05801}{arXiv:2102.05801}.
Raftery, A.E., Sevcikova, H. and Silverman, B.W. (2021). The vote Package: Single Transferable Vote and Other Electoral Systems in R. The R Journal, 13(2), 673-696. \doi{10.32614/RJ-2021-086}.

R.A. Newland and F.S. Britton (1997). How to conduct an election by the Single Transferable Vote. ERS 3rd Edition. \url{http://www.rosenstiel.co.uk/stvrules/index.html}

Expand Down
2 changes: 1 addition & 1 deletion man/vote-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Maintainer: Hana Sevcikova
}

\references{
Raftery, A.E., Sevcikova, H. and Silverman, B.W. (2021). The vote Package: Single Transferable Vote and Other Electoral Systems in R. \href{https://arxiv.org/abs/2102.05801}{arXiv:2102.05801}.
Raftery, A.E., Sevcikova, H. and Silverman, B.W. (2021). The vote Package: Single Transferable Vote and Other Electoral Systems in R. The R Journal, 13(2), 673-696. \doi{10.32614/RJ-2021-086}.
}

\examples{
Expand Down

0 comments on commit 365b0c9

Please sign in to comment.