library("dplyr")
library("viridisLite")
data("USArrests", package = "datasets")
data("usgeojson")
USArrests <- USArrests %>%
mutate(state = rownames(.))
n <- 4
colstops <- data.frame(q = 0:n/n,
c = substring(viridis(n + 1, option = "A"), 0, 7)) %>%
list.parse2()
highchart() %>%
hc_title(text = "Violent Crime Rates by US State") %>%
hc_subtitle(text = "Source: USArrests data") %>%
hc_add_series_map(usgeojson, USArrests, name = "Murder arrests (per 100,000)",
value = "Murder", joinBy = c("woename", "state"),
dataLabels = list(enabled = TRUE,
format = '{point.properties.postalcode}')) %>%
hc_colorAxis(stops = colstops) %>%
hc_legend(valueDecimals = 0, valueSuffix = "%") %>%
hc_mapNavigation(enabled = TRUE)
library("viridisLite")
library("dplyr")
data(unemployment)
data(uscountygeojson)
dclass <- data_frame(from = seq(0, 10, by = 2),
to = c(seq(2, 10, by = 2), 50),
color = substring(viridis(length(from), option = "C"), 0, 7))
dclass <- list.parse3(dclass)
highchart() %>%
hc_title(text = "US Counties unemployment rates, April 2015") %>%
hc_add_series_map(uscountygeojson, unemployment,
value = "value", joinBy = "code") %>%
hc_colorAxis(dataClasses = dclass) %>%
hc_legend(layout = "vertical", align = "right",
floating = TRUE, valueDecimals = 0,
valueSuffix = "%") %>%
hc_mapNavigation(enabled = TRUE)Run the code above in your browser using DataLab