get_clusters: Assign cluster IDs to epicontacts data

Description Usage Arguments Value Author(s) Examples

View source: R/get_clusters.R

Description

This function identifies transitive clusters (i.e. connected components) as well as the number of members in each cluster, and adds this information to the linelist data.

Usage

1
2
3
get_clusters(x, output = c("epicontacts", "data.frame"),
  member_col = "cluster_member", size_col = "cluster_size",
  override = FALSE)

Arguments

x

An epicontacts object.

output

A character string indicating the type of output: either an epicontacts object (default) or a data.frame containing cluster memberships to which members of epicontacts linelist belong to.

member_col

Name of column to which cluster membership is assigned to in the linelist. Default name is 'cluster_member'.

size_col

Name of column to which cluster sizes are assigned to in the linelist. Default name is 'cluster_size'.

override

Logical value indicating whether cluster member and size columns should be overwritten if they already exist in the linelist. Default is 'FALSE'.

Value

An epicontacts object whose 'linelist' dataframe contains new columns corresponding to cluster membership and size, or a data.frame containing member ids, cluster memberships as factors, and associated cluster sizes. All ids that were originally in the 'contacts' dataframe but not in the linelist will also be added to the linelist.

Author(s)

Nistara Randhawa ([email protected])

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (require(outbreaks)) {
## build data
x <- make_epicontacts(ebola_sim$linelist, ebola_sim$contacts,
                       id = "case_id",
                       to = "case_id",
                       from = "infector",
                       directed = TRUE)


## add cluster membership and sizes to epicontacts 'linelist'
y <- get_clusters(x, output = "epicontacts")
y

## return a data.frame with linelist member ids and cluster memberships as
## factors
z <- get_clusters(x, output = "data.frame")
head(z)

}

epicontacts documentation built on May 2, 2019, 11:29 a.m.