Dear list members, I am trying to add a legend to a leaflet map but I got the following error
data(meuse) coordinates(meuse) <- ~x+y proj4string(meuse) <- CRS("+init=epsg:28992") WGS84 <- CRS("+proj=longlat +ellps=WGS84") meuse <- spTransform(meuse, WGS84) pal <- colorFactor(palette = c("red", "blue", "green"), levels = meuse$soil) meuse$soil leaflet(meuse) %>% addTiles() %>% addCircleMarkers(stroke = FALSE, fillOpacity = 1) %>% addLegend("topright", color = ~pal(soil), labels=c("Type 1", "Type 2", "Type 3"), title="Soil type") Duplicate levels detected Show Traceback Error in addLegend(., "topright", color = ~pal(soil), labels = c("Type 1", : 'colors' and 'labels' must be of the same length Best, Manuel -- *Manuel Spínola, Ph.D.* Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA mspin...@una.cr <mspin...@una.ac.cr> mspinol...@gmail.com Teléfono: (506) 8706 - 4662 Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/> [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo