library(leaflet)
load('etfData.RDat')

# The next lines are taken straight from the dataGrab Notebook. 

ytdPal <- colorQuantile("Blues", world_etf$ytd, n = 20)

ytdPopup <- paste0("<strong>Country: </strong>", 
  world_etf$name,
  "<br><strong> Year-to-date: </strong>", 
  world_etf$ytd, "%")

leaf_world_etf <- leaflet(world_etf) %>%
  addProviderTiles("CartoDB.Positron") %>% 
  setView(lng =  20, lat =  15, zoom = 2) %>%
  addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = .7,
    # The next line of code is really important!       
    color =~ytdPal(ytd), layerId = ~ticker, popup = ytdPopup)