I would like to create a choropleth map using leafletR::leaflet. My data comes in SpatialPolygonsDataFrame, and I would like to select a specific column to build.
This sp::spplotis frivolous, as the argument zcolallows me to specify the layer / column built:
library("maptools");library("sp");library("leafletR")
SP <- readShapePoly(system.file("shapes/sids.shp",
package="maptools")[1],
proj4string=CRS("+proj=longlat +datum=WGS84
+no_defs +ellps=WGS84
+towgs84=0,0,0"))
spplot(SP, zcol="BIR79")

However, with leafletR, I don’t know how to specify the layer, and it just draws the borders of a simple map:
SP4leaflet <- toGeoJSON(data=SP, dest=tempdir(), name="BIR79")
SPleaflet <- leaflet(data=SP4leaflet, dest=tempdir(),
title="Trying to plot BIR79",
base.map="osm", popup="*")
SPleaflet

Any ideas on how to choose the right layer / column to be applied with leafletR?
source
share