Description Usage Arguments Value Examples
Creates dynamic chloropleth maps of danish nominating districts
1 2 3 |
value |
is the name of the column in the data where the values are stored |
id |
is the name of the column in the data where the ids are stored |
subplot |
is a string of ids you want to keep - excludes all others |
data |
is the data frame that contains the data to map |
map |
is a TRUE / FALSE of wether a real map should be plotted underneath |
legend |
is a TRUE / FALSE of wether the legend should be plotted |
pal |
is the color palette for the chloropleth |
logcol |
is a TRUE / FALSE of wether the chloropleth colors should be drawn against the log value |
legendtitle |
provides an alternative title for the legend |
An interactive Leaflet map
1 2 3 4 5 6 7 8 9 10 11 12 | library(leafletDK)
fv15tot <- readr::read_csv2("http://api.statbank.dk/v1/data/FV15TOT/CSV?VALRES=VAELG%2C13&OMR%C3%85DE=*")
fv15tot <- tidyr::spread(fv15tot, VALRES, INDHOLD)
fv15tot <- dplyr::select(fv15tot, -TID)
names(fv15tot) <- c("area", "writing", "voters")
fv15tot <- dplyr::mutate(fv15tot, pertenthousand = writing/(voters/10000))
fv15tot <- dplyr::filter(fv15tot, stringr::str_detect(fv15tot$area, "OPSTILLINGSKREDS"))
fv15tot <- dplyr::mutate(fv15tot, area = stringr::str_to_lower(stringr::str_replace_all(area, "( OPSTILLINGSKREDS)|(\\d+[.] )", "")))
districtDK("pertenthousand", "area", data = fv15tot)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.