knitr::opts_chunk$set( collapse = TRUE, dpi=200, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Allows the user to generate and execute select, insert, update and delete 'SQL' queries the underlying database without having to explicitly write 'SQL' code.
| Release | Usage | Development |
|:--------|:------|:------------|
|| |
|
|
| |
|
|||
|
# Not yet published in CRAN # install.packages("ElectionsLATAM")
Install the R package using the following commands on the R console:
devtools::install_github("rOpenStats/ElectionsLATAM", build_opts = NULL)
To get started execute the following commands:
# 0. Load libraries library(ElectionsLATAM) library(dplyr) library(readr)
# 1. Costa Rica costa.rica.ein.path <- file.path(getPackageDir(), "costa-rica") ecological.inference.calvo <- EcologicalInferenceStrategyCalvoEtAl$new() costa.rica.ein <- EcologicalInferenceProcessor$new( ecological.inference.strategy = ecological.inference.calvo, election.name = "2022-costa-rica-general-ballotage-n4", scenario = "final", data.input.path = costa.rica.ein.path, input.file = "2021-generales_pivot_candidatos_n4.csv", location.fields = c("id_unidad"), votes.field = "votos", #potential.votes.field = "habilitados", ignore.fields = "habilitados", col.types = cols( .default = col_number(), id_unidad = col_character() ) ) dummy <- costa.rica.ein$loadInputPivotCandidatos() costa.rica.ein$output.election <- readr::read_delim( #ballotage.processor$pivot.filepath, file.path(costa.rica.ein.path, paste("2022-ballotage_pivot_candidatos_n4.csv", sep = "_")), delim = ";", col_types = cols( .default = col_double(), id_unidad = col_character() ) ) costa.rica.ein$runScenario(include.blancos = TRUE, include.ausentes = TRUE, max.potential.votes.rel.dif = 0.32) costa.rica.test.path <- file.path(tempdir(), "test","costa-rica") costa.rica.ein$exportBetab(output.folder = costa.rica.test.path, overwrite = TRUE) dummy <- costa.rica.ein$generateOutputJSON(costa.rica.test.path, filename = "balotaje_n4_ei.json") costa.rica.ein$makeSankeyDiagram(output.path = costa.rica.test.path) # Saving output table for reproducibility # write_rds(costa.rica.ein$output.table, file.path(costa.rica.ein.path, "ein_2021_general_2022_ballotage.rds"))
Please note that the 'ElectionsLATAM' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.