get_pairwise: Characterise contacts by comparing case attributes

View source: R/get_pairwise.R

get_pairwiseR Documentation

Characterise contacts by comparing case attributes

Description

This function extract attributes of cases involved in contacts using case information provided in the linelist of an epicontacts dataset. If not provided, the function used to process attributes will adjust to the type of attribute selected (see details).

Usage

get_pairwise(x, attribute, f = NULL, hard_NA = TRUE)

Arguments

x

an epicontacts object

attribute

the attribute to be examined between contact pairs

f

a function processing the attributes of 'from' and 'to'

hard_NA

a logical indicating if the output should be NA whenever one of the paired values is NA (TRUE, default); otherwise, 'NA' may be treated as another character (e.g. when pasting paired values)

Author(s)

Thibaut Jombart (thibautjombart@gmail.com) Tom Crellen (tomcrellen@gmail.com)

Examples

if (require(outbreaks)) {
## example using MERS outbreak in Korea, 2014
head(mers_korea_2015[[1]])
head(mers_korea_2015[[2]])

x <- make_epicontacts(linelist=mers_korea_2015[[1]],
contacts=mers_korea_2015[[2]], directed=TRUE)

## estimate serial interval (onset->onset)
SI <- get_pairwise(x, "dt_onset")
SI
summary(SI)
hist(SI, col="grey", border="white", xlab="Days after symptoms",
     main="MERS Korea 2014 - Serial Interval")

## check gender mixing:
get_pairwise(x, "sex") # not good, we want 2-way table

get_pairwise(x, "sex", f=table) # use custom function
fisher.test(get_pairwise(x, "sex", f=table)) # test association
}

Hackout3/epicontacts documentation built on March 2, 2024, 5:40 a.m.