Description Usage Arguments Objects from the class obkContacts Slots Methods Author(s) Examples
The class obkContacts
is a formal (S4) class for storing
contact data between individuals. Contacts can be static, or change in
time (dynamic) at specified dates. Contacts are handled as
network
and networkDynamic
objects, for static and
dynamic contacts, respectively. See the corresponding packages for
more information on this data structure.
An obkContacts
object can be constructed from individual
identifiers (stored as character
vectors), representing the
'sender' and 'receiver' individuals, whether the contacts should be
regarded as directed, with optional information about the timing of
contacts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | get.contacts(x, ...)
get.ncontacts(x, ...)
## S4 method for signature 'obkContacts'
get.ncontacts(x, from=NULL, to=NULL, ...)
## S4 method for signature 'obkContacts'
get.contacts(x, from=NULL, to=NULL, ...)
## S4 method for signature 'obkContacts'
show(object)
## S4 method for signature 'obkContacts'
plot(x, y=NULL, labels=get.individuals(x),
...)
## S4 method for signature 'obkContacts'
as.matrix(x,
matrix.type=c("adjacency","incidence","edgelist"),
use.labels=TRUE, ...)
## S4 method for signature 'obkContacts'
as.data.frame(x, row.names=NULL, optional=FALSE,
use.labels=TRUE, ...)
|
x,object |
an obkContacts object. |
y |
used for compatibility with the generic definition of
|
labels |
a vector of characters giving annotation for the vertices. |
matrix.type |
a character indicating which type of matrix to extract(adjacency, incidence, or edge matrix). |
from,to |
dates indicating the time span to consider for active contacts (for dynamic networks only). |
... |
arguments passed to other methods; currently not used,
except for |
row.names,optional |
unused arguments, there for compatibility
with the generic |
use.labels |
a logical indicating whether labels should be used to indicate individuals, as opposed to their index in the network. |
obkContacts
objects can be created by calls to
new("obkContacts", ...)
, where '...' can be the following
arguments:
from
a vector of individual identifiers in
character
format representing the source of the contact.
to
a vector of individual identifiers in
character
format representing the sink of the contact.
directed
a Boolean for whether contacts should be
regarded as directed (TRUE
) or not (FALSE
).
start
an optional vector of times representing the start of a contact; can be dates or numeric values.
end
an optional vector of times representing the end of a contact; can be dates or numeric values..
duration
an optional vector of durations of a contact,
as an alternative way of representing dynamic contacts than using
end
; if numeric values are used together with dates in
'start' and 'end', these will be interpreted as numbers of days.
The following slots are the content of instances of the class
obkContacts
; note that in most cases, it is better to retrieve
information via accessors (see below), rather than by accessing the
slots manually.
contacts
:an object of class network
or networkDynamic
.
origin
:an object of class Date
indicating the
origin of the contacts (i.e., this corresponds to "day 0".
Here is a list of methods available for obkContacts
objects. Most of these methods are accessors, that is, functions which
are used to retrieve the content of the object. Specific manpages can
exist for accessors with more than one argument. These are indicated
by a '*' symbol next to the method's name. This list also contains
methods for conversion from obkContacts
to other classes.
signature(x = "obkContacts")
: printing of the
object.
signature(x = "obkContacts", y=NULL)
: plot the
contact network; relies on plot.network
, to
which arguments can be passed via ...
.
signature(x = "obkContacts")
: returns
the number of contacts; for dynamic contact
networks, starting dates can be specified by the argument
from
, and end date by the argument to
.
signature(x = "obkContacts")
: returns
the contacts (as network
or networkDynamic
); for
dynamic contact networks, starting dates can be specified by the
argument from
, and end date by the argument to
.
signature(x = "obkContacts")
: returns the number of
individuals in the contact data (see manpage
of get.individuals
for details)..
signature(x = "obkContacts")
: returns
the identifiers of individuals in the contact data(see manpage
of get.individuals
for details)..
signature(x = "obkContacts")
: returns the number of
dates at which contact structure changes (see manpage of
get.dates
for details).
signature(x = "obkContacts")
: returns the
dates at which contact structure changes (see manpage of
get.dates
for details).
signature(x = "obkContacts",
matrix.type=c("adjacency","incidence","edgelist"))
: extract an
adjacency, incidence, or edge matrix from the object.
signature(x = "obkContacts", ...)
: for
static contacts, returns an edge list; for dynamic contacts, returns
and edge list with information on the timing of contacts.
Original class: Simon Frost (sdwfrost@gmail.com)
Plot, various accessors, conversion methods: Thibaut Jombart (tjombart@imperial.ac.uk)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ## THIS IS A TOY EXAMPLE ##
cf <- c("a", "b", "a", "c", "d")
ct <- c("b", "c", "c", "d", "b")
onset <- c(1, 2, 3, 4, 5)
terminus <- c(1.2, 4, 3.5, 4.1, 6)
oc.static <- new("obkContacts",cf,ct,FALSE) # static network
oc.dynamic <- new("obkContacts",cf,ct,FALSE,onset,terminus)
oc.static
oc.dynamic
plot(oc.static, main="Contact network")
## PLOTTING A DYNAMIC CONTACT NETWORK ##
## LOAD DATA
data(ToyOutbreak) # ToyOutbreak includes a dynamic contact network
## PLOT THE STATIC NETWORK
plot(ToyOutbreak@contacts)
## PLOT THE DYNAMIC NETWORK OVER THE FIRST 4 DAYS OF THE OUTBREAK
par(mfrow=c(2,2))
plot(ToyOutbreak@contacts)
plot(get.contacts(ToyOutbreak, from=0, to=2), displaylabels=TRUE,
main="Contact network - days 1-2")
plot(get.contacts(ToyOutbreak, from=2.9, to=3.1), displaylabels=TRUE,
main="Contact network - day 3")
plot(get.contacts(ToyOutbreak, from=3.9, to=4.1), displaylabels=TRUE,
main="Contact network - day 4")
par(mfrow=c(1,1))
# extract matrices of adjacency, incidence, or edge list
as.matrix(ToyOutbreak@contacts)
as.matrix(ToyOutbreak@contacts, "incidence")
as.matrix(ToyOutbreak@contacts, "edgelist")
as.data.frame(ToyOutbreak@contacts)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.