Description Usage Arguments Value
View source: R/elec_results_map.R
elec_results_map STILL IN PROGRESS! This function takes a vote results file that has been run through the elec_find_winner and elec_pcts_by_row functions and combined with a GIS shapefile. The result is a Leaflet map with diverging colors for the winning and losing candidates/positions, and an optional turnout layer. Vignette to come.
1 2 3 | elec_winners_map(gisdatafile, winner = "Yes", loser = "No",
placeCol = "Precinct", wincolors = "Greens", losecolors = "Reds",
turnout = TRUE, turnoutcolors = "Greens", WinPctMargin = "YesPctMargin")
|
gisdatafile |
- sf (simple features) geospatial file combined with vote results data that was already processed with elec_find_winner and elec_pcts_by_row |
winner |
- string name of winning candidate or position |
loser |
- string name of losing candidate or position |
placeCol |
- string name of column that holds place names. If you want names to display as "Precinct 1" you must have a placeCol column that combines the string "Precinct " with the precinct number. |
wincolors |
- string name of ColorBrewer palette. Defaults to "Greens." |
losecolors |
- string name of ColorBrewer palette. Defaults to "Reds." |
turnout |
- logical Whether data includes a column named Turnout with turnout percents as a fraction |
turnoutcolors |
- string name of ColorBrewer palette. Defaults to "Greens." |
WinPctMargin |
- string name of column with the difference between the winning percent and losing percent for each place. May need to be calculated manually. |
leaflet object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.