Learn R Programming

epicontacts (version 1.1.0)

subset_clusters_by_size: Subset clusters from epicontacts object by cluster size

Description

This function subsets an epicontacts object based on defined size(s) of clusters (clusters being groups of connected individuals/nodes). Subsetting may be done by specifying a particular cluster size of interest, minimum cluster size, maximum cluster size, or a range (minimum and maximum) of cluster sizes.

Usage

subset_clusters_by_size(x, cs = NULL, cs_min = NULL, cs_max = NULL)

Arguments

x

an epicontacts object

cs

cluster size to be used for subsetting

cs_min

minimum cluster size for subsetting

cs_max

maximum cluster size for subsetting

Value

An epicontacts object whose contact dataframe corresponds to all clusters of specified cluster sizes.

Examples

Run this code
# NOT RUN {
if (require(outbreaks)) {
## build data
x <- make_epicontacts(ebola_sim$linelist, ebola_sim$contacts,
                       id="case_id", to="case_id", from="infector",
                       directed=TRUE)


## subset based on cluster size range
x_subset <- subset_clusters_by_size(x, cs_min = 12, cs_max = 15)


## subset based on single cluster size
x_subset <- subset_clusters_by_size(x, cs = 12)


## subset based on minimum cluster size
x_subset <- subset_clusters_by_size(x, cs_min = 10)


## subset based on maximum cluster size
x_subset <- subset_clusters_by_size(x, cs_max = 9)
}
# }

Run the code above in your browser using DataLab