Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am leonallen22 on github.
  • I am leon_allen (https://keybase.io/leon_allen) on keybase.
  • I have a public key whose fingerprint is 441B 3AD9 851D 5E3D D4ED 0141 6103 1E80 D2A0 F303

To claim this, I am signing this object:

@leonallen22
leonallen22 / helpers.R
Created April 4, 2017 20:21
Data Science Assignment
# 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)