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 )
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 |
from | an index or name indicating which column in |
to | an index or name indicating which column in |
directed | a logical indicating if contacts are directed or not; default
is |
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
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.
https://foodborne.unl.edu/public/role/epidemiologist/lineLists.html
Thibaut Jombart (thibautjombart@gmail.com)
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