subset_clusters_by_size: Subset clusters from epicontacts object by cluster size

View source: R/subset_clusters_by_size.R

subset_clusters_by_sizeR Documentation

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.

Author(s)

Nistara Randhawa (nrandhawa@ucdavis.edu)

Examples

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)
}

reconhub/epicontacts documentation built on Feb. 28, 2024, 3:15 p.m.