Description Usage Arguments Examples
Add choropleth data.
| 1 2 3 4 5 6 7 | add_choropleth(
  p,
  locations,
  color,
  ...,
  colors = c("#FFEDA0", "#FEB24C", "#F03B20")
)
 | 
| p | a datamaps object. | 
| locations | column containing location names as  | 
| color | column containing color of each  | 
| ... | any other variable to use for tooltip. | 
| colors | color palette. | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | data <- data.frame(name = c("USA", "FRA", "CHN", "RUS", "COG", "DZA"),
    color = round(runif(6, 1, 10)))
data %>%
    datamaps() %>%
    add_choropleth(name, color, colors = c("skyblue", "yellow", "orangered"))
# categorical colors
cat <- data.frame(name = c("USA", "BRA", "COL", "CAN", "ARG", "CHL"),
    col = rep(c("Yes", "No"), 6))
cat %>%
    datamaps(projection = "orthographic") %>%
    add_choropleth(name, col, colors = c("red", "blue"))
# US states
states <- data.frame(st = c("AR", "NY", "CA", "IL", "CO", "MT", "TX"),
    val = c(10, 5, 3, 8, 6, 7, 2))
states %>%
    datamaps(scope = "usa", default = "lightgray") %>%
    add_choropleth(st, val) %>%
    add_labels()
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.