Learn R Programming

scanstatistics (version 0.1.0)

top_clusters: Get the top (non-overlappig) clusters.

Description

Get the top \(k\) space-time clusters according to the statistic calculated for each cluster (the maximum being the scan statistic). The default is to return the spatially non-overlapping clusters, i.e. those that do not have any locations in common.

Usage

top_clusters(x, k = 5, overlapping = FALSE)

Arguments

x

An object of class scanstatistics.

k

An integer, the number of clusters to return

overlapping

Logical; should the top clusters be allowed to overlap in the spatial dimension? The default is FALSE.

Value

A data.table with at most \(k\) rows, with columns zone, duration, statistic.

Examples

Run this code
# NOT RUN {
set.seed(1)
table <- scanstatistics:::create_table(list(location = 1:4, duration = 1:4), 
                                        keys = c("location", "duration"))
table[, mu := 3 * location]
table[, count := rpois(.N, mu)]
table[location %in% c(1, 4) & duration < 3, count := rpois(.N, 2 * mu)]
zones <- scanstatistics:::powerset_zones(4)
result <- scan_poisson(table, zones, 0)
top_clusters(result, k = 4, overlapping = FALSE)
# }

Run the code above in your browser using DataLab