knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This API function designed to recall election results for different parties whom participates in Swedish election for the years 2010, 2014 and 2018, and then visualize the results to show the distribution of election per party among counties.
apivalm
is available through GitHub.
To install the latest development version from GitHub:
install.packages("devtools") devtools::install_github("Elmahi92/apivalm")
Start by defining in which year you want to see the election results, note that the only years available are (2010,2014 and 2018), and error massage “Incorrect year! Data is only available for 2010, 2014 and 2018." will be displayed if you type different year than the stated ones, Start by install the package by typing the command
library(valmyndigheten_get)
Define which year you want to have results for and type the year, then define the election type, for this package three types of elections are defined, Riksdag, County and Municipal. Note that an error massage "Incorrect election type! Available election types are Riksdag, county and municipal." will be displayed if you typed any other type of election than the stated ones (Riksdag, County and Municipal)
valmyndigheten_get(year,election_types)
A table with the selected year and election type will be generated.
valmyndigheten_get(year,election_types)
Data view will consist of main variables which are
Year | Election | type County code | Municipality code | County | Municipality
valmyndigheten_get(2018,"county")
The package also have a data visualization tool using Shiny app to, in which counts, percentages per County and Municipal are plot , year also can be defined to better understand the election results.
valmyndigheten_get(2018,"county")
The package comes with a shiny app that's allow for data visualization and reporting the election base on different pre-selected fields
runExample()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.