I have a dataframe [df], just like this:
id lat long category
1 -103.3671 43.0835 0 to 0.5
2 -103.3634 43.0855 0 to 0.5
3 -103.3684 43.0884 0.5 to 1
4 -103.3613 43.0835 1 to 1.5
I would like to know how to display these points in a leaflet map with a different colour for each category? I have 5 categories in total.
I tried something like this, but without success:
pal <- colorNumeric(palette = "RdYlBu", domain = df$category)
leaflet(df) %>%
addCircles(lng = ~long, lat = ~lat, color = ~pal(category), fillColor = ~pal(category), fillOpacity = 0.7, radius = 10, stroke = FALSE)
When defining the 'pal', I get an error: Wasn't able to determine range of domain.
Is there any solution to this? Thank you for any suggestions.