add.methods | R Documentation |
The methods (add.vertices.networkDynamic
, add.edge.networkDynamic
, add.edges.networkDynamic
) override their network-package counterparts in order to permit assigning persistent.ids to newly-added elements if the pid is defined. They can be defined by the user with the vertex.pids
argument, or, if not specified, a unique random id will be generated. (Note that any new values added by default to a vertex.names
pid will not be numeric.)
## S3 method for class 'networkDynamic'
add.vertices(x, nv, vattr = NULL, last.mode = TRUE,
vertex.pid = NULL, ...)
## S3 method for class 'networkDynamic'
add.edges(x, tail, head, names.eval = NULL, vals.eval = NULL,
edge.pid = NULL, ...)
## S3 method for class 'networkDynamic'
add.edge(x, tail, head, names.eval = NULL, vals.eval = NULL,
edge.check = FALSE, edge.pid = NULL, ...)
x |
an object of class |
nv |
number of vertices to be added. (see |
vattr |
optionally, a list of attributes with one entry per new vertex. (see |
last.mode |
logical; should the new vertices be added to the last (rather than the first) mode of a bipartite network? (see |
vertex.pid |
a vector of vertex.pids to be assigned to the newly-added vertices |
edge.pid |
a vector of edge.pids to be assigned to the newly-added edges |
names.eval |
see |
vals.eval |
see |
edge.check |
see |
head |
see |
tail |
see |
... |
possible additional arguments |
The networkDynamic versions of these methods call the network versions internally. See persistent.ids for additional details about the PID mechanism.
add.verticies
(invisibly) returns a reference to the network with the new vertices added. Pids will be added/created if a vertex.pid
attribute is set.
add.edge
and add.edges
(invisibly) return a reference to the network with the new edges added. Pids will be added/created if a vertex.pid
attribute is set.
Adding edges via the extraction/replacement operators [,]
bypasses the pid code and will break the edge pids defined for the network. Similarly, add.vertices.active
and add.edges.active
do not yet support including pids.
lxwang, skyebend, the statnet team
See also persistent.ids
, add.vertices
, add.edge
, add.edges
in network.
# add vertices while using vertex.names as pids
nd <- as.networkDynamic(network.initialize(3))
set.network.attribute(nd,"vertex.pid","vertex.names")
add.vertices(nd,nv=2,vertex.pid=c(4,5)) # specify pids for two new vertices
network.vertex.names(nd) # peek at pids
# add vertices and edges w/ auto-generated pids
nd <- as.networkDynamic(network.initialize(3))
initialize.pids(nd)
get.vertex.attribute(nd,'vertex.pid') # peek at pids
add.vertices(nd,nv=2) # silently generate pids for vertices
get.vertex.attribute(nd,'vertex.pid') # peek at pids
add.edges(nd,1,2) # silently generate a pid for the edge
get.edge.attribute(nd,'edge.pid')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.