choropleth | R Documentation |
Display choropleth map of detected clusters.
choropleth( polygons, fls, col = palette(), region_color = "#F0F0F0", rank = 1:length(fls$cluster), pval = 1, ... )
polygons |
A SpatialPolygonsDataFrame. |
fls |
An rflexscan object. |
col |
A vector of colors for each cluster. |
region_color |
Color of regions that are not included in any clusters. |
rank |
An integer vector which specifies ranks of clusters to be displayed. |
pval |
A threshold of P-value. Clusters with P-values of < |
... |
Other parameters to be passed to plot function. |
Clusters are colored using the current palette. Please use palette function to specify colors of each cluster. Note that clusters with ranks larger than the number of colors in the palette are not highlighted.
rflexscan
# load sample data (North Carolina SIDS data) library(sf) library(spdep) data("nc.sids") sids.shp <- read_sf(system.file("shapes/sids.shp", package="spData")[1]) # calculate the expected numbers of cases expected <- nc.sids$BIR74 * sum(nc.sids$SID74) / sum(nc.sids$BIR74) # run FleXScan fls <- rflexscan(x = nc.sids$x, y = nc.sids$y, observed = nc.sids$SID74, expected = expected, name = rownames(nc.sids), clustersize = 10, nb = ncCR85.nb) # display all clusters choropleth(sids.shp, fls) # display clusters with rank 1, 2 and 3 choropleth(sids.shp, fls, rank = c(1, 2, 3)) # display clusters of P-value <= 0.05 choropleth(sids.shp, fls, pval = 0.05)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.