Description Usage Arguments Value Examples
The sp
package has a number of classes of SpatialXDataFrames like SpatialPolygonDataFrame. These include both data.frame content (in their @data
slot) as well as the spatial information (polygons, points, etc.; in their @polygons
, @points
, etc. slots). This function replaces the data.frame that would normally come from the topo- or geo-json with a CrunchDataFrame that includes all of the same information as the original data.frame, but also with information about the CrunchDataSet (similar to using as.data.frame(dataset)
).
1 | getGeoDataFrame(geo_var, data, ...)
|
geo_var |
the alias of the variable that has geodata associated with it |
data |
a Crunch dataset object |
... |
passed to |
a SpatialDataFrame with a CrunchDataFrame in the Data
slot instead
of a standard data.frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
library(leaflet)
ds_geodata <- getGeoDataFrame("state", ds)
# a very simple leaflet choropleth
pal <- colorNumeric(
palette = "viridis",
domain = ds_geodata$turnout)
leaflet(ds_geodata) %>%
addPolygons(color = "#444444", weight = 0.5, smoothFactor = 0.5,
opacity = 0.75, fillOpacity = 0.85,
fillColor = ~pal(turnout))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.