This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: percent map is designed to work with the counties data set | |
# It may not work correctly with other data sets if their row order does | |
# not exactly match the order in which the maps package plots counties | |
percent_map <- function(var, color, legend.title, min = 0, max = 100) { | |
# generate vector of fill colors for map | |
shades <- colorRampPalette(c("white", color))(100) | |
# constrain gradient to percents that occur between min and max | |
var <- pmax(var, min) |