This function reads data stored as data.frame containing linelist (case information, where each row corresponds to a unique patient), and contacts between patients. Common identifiers should be used in the two data sources for matching to be achieved.

make_epicontacts(linelist, contacts, id = 1L, from = 1L, to = 2L,
  directed = FALSE)

Arguments

linelist

a data.frame with at least one column providing unique patient identifiers

contacts

a data.frame that needs at least two columns indicating patients between which cases take place; these need not be referenced in the linelist

id

an index or name indicating which column in linelist contains unique identifiers; default is first column in linelist data frame

from

an index or name indicating which column in contacts contains the first case of a contact

to

an index or name indicating which column in contacts contains the second case of a contact

directed

a logical indicating if contacts are directed or not; default is FALSE but note that contacts will be indicated as 'from' and 'to' even in non-directed contacts

Value

An epicontacts object in list format with three elements:

  • linelist: data.frame of cases with first column 'id' containing character vector of unique identifiers

  • contacts: data.frame of contacts with first two columns named 'from' and 'to' indicating unique pairs of contact between individuals

  • directed: indicator as to whether or not the contacts are to be considered directed or not

Details

An epicontacts object can be created from two components:

  • a linelist provided as a data.frame where columns are different variables describing cases, and where each row is a different case. and a contact list.

  • a contact list provided as a data.frame where each row contains unique pairs of contacts with unique features of contact in columns. The line list and contact list should share an identification scheme for individuals.

References

http://foodborne.unl.edu/public/role/epidemiologist/lineLists.html

Examples

if (require(outbreaks)) { ## make epicontacts object from simulated Ebola data x <- make_epicontacts(ebola_sim$linelist, ebola_sim$contacts) ## test reordering of columns linelist <- ebola_sim$linelist[,rev(seq_len(ncol(ebola_sim$linelist)))] contacts <- ebola_sim$contacts[,rev(seq_len(ncol(ebola_sim$contacts)))] head(linelist) head(contacts) ## make object x <- make_epicontacts(linelist, contacts, id = "case_id", to = "case_id", from = "infector") head(x$linelist) head(x$contacts) }
#> from to source #> 2 d1fafd 53371b other #> 3 cac51e f5c3d8 funeral #> 5 f5c3d8 0f58c4 other #> 8 0f58c4 881bd4 other #> 11 8508df 40ae5f other #> 12 127d83 f547d6 funeral