diff --git a/R/data.R b/R/data.R index e8e1204..cd463ae 100644 --- a/R/data.R +++ b/R/data.R @@ -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 diff --git a/R/shinyapp.R b/R/shinyapp.R index 1be554e..4740631 100644 --- a/R/shinyapp.R +++ b/R/shinyapp.R @@ -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) { diff --git a/data-raw/shinyapp_examples.R b/data-raw/shinyapp_examples.R index 4b405f8..781a654 100644 --- a/data-raw/shinyapp_examples.R +++ b/data-raw/shinyapp_examples.R @@ -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 ) ) diff --git a/data-raw/uri2020.R b/data-raw/uri2020.R new file mode 100644 index 0000000..d7fb758 --- /dev/null +++ b/data-raw/uri2020.R @@ -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) diff --git a/data/uri2020.rda b/data/uri2020.rda new file mode 100644 index 0000000..62f602a Binary files /dev/null and b/data/uri2020.rda differ diff --git a/man/run_app.Rd b/man/run_app.Rd index fd61891..08c89b8 100644 --- a/man/run_app.Rd +++ b/man/run_app.Rd @@ -23,6 +23,6 @@ if(interactive()){ 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) } } diff --git a/man/uri2020.Rd b/man/uri2020.Rd new file mode 100644 index 0000000..7b0866a --- /dev/null +++ b/man/uri2020.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{uri2020} +\alias{uri2020} +\title{Election Data for the Cantonal Council of Uri (2020)} +\format{ +List containing: +\itemize{ +\item{\code{votes_matrix} the number of votes for each party and district +(4 rows, 4 columns)} +\item{\code{seats_vector} with the number of seats per district +(length 4)} +} +} +\source{ +\url{https://www.ur.ch/abstimmungen/termine/9322} +} +\usage{ +uri2020 +} +\description{ +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". +} +\keyword{data} diff --git a/man/zug2018.Rd b/man/zug2018.Rd index 378a0da..9b3440a 100644 --- a/man/zug2018.Rd +++ b/man/zug2018.Rd @@ -15,7 +15,7 @@ Kanton Zug (01.07.2022, 10:27:58). Kantonsratswahl 2018 (CSV). zug2018 } \description{ -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. } \keyword{data}