View source: R/color.clusters.R
color.clusters | R Documentation |
color.clusters
is a helper function to color
clusters of regions produced by an appropriate method,
e.g., scan.test
or uls.test
. Regions that
are not part of any cluster have no color.
color.clusters( x, idx = seq_along(x$clusters), col = grDevices::hcl.colors(length(idx)) )
x |
An object of class scan produced by a function
such as |
idx |
An index vector indicating the elements of
|
col |
A vector of colors to color the clusters in
|
Returns a vector with colors for each
region/centroid for the data set used to construct
x
.
Joshua French
data(nydf) coords <- with(nydf, cbind(longitude, latitude)) out <- scan.test( coords = coords, cases = floor(nydf$cases), pop = nydf$pop, alpha = 0.2, longlat = TRUE, nsim = 9 ) data(nypoly) library(sp) # plot all clusters plot(nypoly, col = color.clusters(out), axes = TRUE) # zoom in on small cluster plot(nypoly, col = color.clusters(out), xlim = c(400000, 450000), ylim = c(4750000, 4800000) ) # plot only clusters 1 and 3 plot(nypoly, col = color.clusters(out, idx = c(1, 3)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.