Learn R Programming

smerc (version 1.4.2)

color.clusters: Color clusters

Description

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.

Usage

color.clusters(x, col = grDevices::hcl.colors(length(x$clusters)))

Arguments

x

An object of class scan produced by a function such as scan.test.

col

A vector of colors to color the clusters in x. Should have same length as the number of clusters in x.

Value

Returns a vector with colors for each region/centroid for the data set used to construct x.

Examples

Run this code
# NOT RUN {
data(nydf)
coords = with(nydf, cbind(longitude, latitude))
out = scan.test(coords = coords, cases = floor(nydf$cases),
                pop = nydf$pop, alpha = 0.12, longlat = TRUE,
                nsim = 9)
data(nypoly)
library(sp)
plot(nypoly, col = color.clusters(out))
# }

Run the code above in your browser using DataLab