Skip to content

Commit

Permalink
add uri2020 dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
polettif committed Feb 14, 2024
1 parent ae66d57 commit f0d4ff2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
22 changes: 20 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
#' Election Data for the Cantonal Council of Zug (2018)
#'
#' Example election data from the 2018 election for cantonal council of Zug in
#' Switzerland.
#' Example election data from the 2018 election for the cantonal council
#' of Zug (Kantonsrat) in Switzerland.
#'
#' @source Kanton Zug (01.07.2022, 10:27:58). Kantonsratswahl 2018 (CSV).
#' \url{https://wab.zug.ch/elections/kantonsratswahl-2018/data-csv}
#' @keywords data
"zug2018"

#' Election Data for the Cantonal Council of Uri (2020)
#'
#' Example election data from the 2020 election for the cantonal council
#' of Uri (Landrat) in Switzerland. The data has been extracted from the report
#' "Landratswahlen 2020: Statistische Auswertung".
#'
#' @format List containing:
#' \itemize{
#' \item{`votes_matrix` the number of votes for each party and district
#' (4 rows, 4 columns)}
#' \item{`seats_vector` with the number of seats per district
#' (length 4)}
#' }
#'
#' @source \url{https://www.ur.ch/abstimmungen/termine/9322}
#' @keywords data
"uri2020"

#' Finnish Parliamentary Elections Data (2019)
#'
#' Example data from the 2019 Finnish parliamentary elections. The data has been
Expand Down
2 changes: 1 addition & 1 deletion R/shinyapp.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' run_app()
#'
#' # It's possible to load a matrix with the app
#' run_app(proporz:::shinyapp_examples$uri_2020$votes, proporz:::shinyapp_examples$uri_2020$seats)
#' run_app(uri2020$votes_matrix, uri2020$seats_vector)
#' }
#' @export
run_app = function(votes_matrix = NULL, district_seats = NULL) {
Expand Down
9 changes: 2 additions & 7 deletions data-raw/shinyapp_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ shinyapp_examples = list(
seats = c(4, 5, 6)
),
uri_2020 = list(
votes = structure(c(11471L, 11908L, 9213L, 7756L, 2822L,
1606L, 1567L, 2945L, 2309L, 1705L,
946L, 1573L, 4794L, 2600L, 2961L, 3498L),
.Dim = c(4L, 4L), .Dimnames = list(
c("CVP", "SPGB", "FDP", "SVP"),
c("Altdorf", "B\u00fcrglen", "Erstfeld", "Schattdorf"))),
seats = c(15, 7, 6, 9)
votes = uri2020$votes_matrix,
seats = uri2020$seats_vector
)
)

Expand Down
15 changes: 15 additions & 0 deletions data-raw/uri2020.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
uri2020 = list(
votes_matrix = structure(
c(11471L, 11908L, 9213L, 7756L, 2822L,
1606L, 1567L, 2945L, 2309L, 1705L,
946L, 1573L, 4794L, 2600L, 2961L, 3498L),
.Dim = c(4L, 4L),
.Dimnames = list(
c("CVP", "SPGB", "FDP", "SVP"),
c("Altdorf", "B\u00fcrglen", "Erstfeld", "Schattdorf"))),
seats_vector = c(15, 7, 6, 9)
)

names(uri2020$seats_vector) <- colnames(uri2020$votes_matrix)

usethis::use_data(uri2020, overwrite = TRUE)
Binary file added data/uri2020.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/run_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/uri2020.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/zug2018.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0d4ff2

Please sign in to comment.