View source: R/make_epicontacts.R
make_epicontacts | R Documentation |
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 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.
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
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.