So I am working on an interactive map of Jordan, to display registered Syrian refugees per governorate. The interactivity added is pretty simple; using add_tooltip, once you hover over a governorate it shows the name and the total number of refugees. However it does not show the name. When I use print or format on it, it then shows 'NULL'. What could be the reason?
A reproducible code can be found below:
library(choroplethrAdmin1)
library(choroplethr)
library(ggvis)
library(dplyr)
jor<-get_admin1_map("jordan")
jor %>% ggvis(~long, ~lat) %>%
layer_paths(data = jor %>% group_by(group),
strokeWidth := 0, fill = ~total) %>%
hide_axis("x") %>% hide_axis("y") %>%
add_tooltip(function(data){paste("Gov: ", data$name, "<br>", "Total: ", as.character(data$lat))}, "hover")