I am trying to create a Highchart Map of Europe with R for categories instead of numbers.
Lets say I have the dataset below and I want that the Map shows a color for each category. Categories are: "Red", "Blue", "Green".
library(highcharter)
mapData <- data_frame(country = c("PT", "FR", "IT", "DE"),
value = c("Red","Blue","Green","Red"))
Then I need the map to show the categories:
hcmap(map = 'custom/europe', data = mapData,
joinBy = c("iso-a2","country"), value = "value")
The problem is that the result gives me black for each country in my data frame
.
Here is a suggestion for a possible solution:
mapData <- tibble(country = c("PT", "FR", "IT", "DE"),
value = c(1, 2, 3, 1))
hcmap(map = 'custom/europe', data = as.data.frame(mapData),
joinBy = c("iso-a2","country"), value = "value") %>%
hc_colorAxis(dataClassColor="category",
dataClasses = list(list(from=1, to=1, color="red", name="PT-DE"),
list(from=2, to=2, color="blue", name="FR"),
list(from=3, to=3, color="green", name="IT")))