Map with color coordinates according to some variables

Viewed 21

I am trying to create a distribution map with the "leaflet" package following some coordinates. I have created (I think well) a color palette according to the name of some species and the map with this command:

pal <- colorFactor(palette = c(1:7), 
levels = c("Bottlenose dolphin","Common dolphin","Cuvier's
beaked whale","Long-finned pilot whale","Risso's dolphin","Sperm whale","Striped dolphin"))

leaflet() %>% 
  addProviderTiles("CartoDB") %>% 
   addCircleMarkers(lng = dfsensedsp$`Start Longitude`, lat = dfsensedsp$`Start Latitud`, radius=.2, color=pal(dfsensedsp$Specie))

When I do this, it returns me this error: Error in UseMethod("toPaletteFunc") : no applicable method for 'toPaletteFunc' applied to an object of class "c('integer', 'numeric')"

What do you think I should do to eliminate this error, and get a map with different coordinate points, with a different color for each species

0 Answers
Related