network.naedgecount returns the number of edges within a
network object which are flagged as missing. The
is.na network method returns a new network containing the missing edges.
1 2 3
an object of class
The missingness of an edge is controlled by its
na attribute (which is mandatory for all edges);
network.naedgecount returns the number of edges for which
is.na network method produces a new network object whose edges correspond to the missing (
na==TRUE) edges of the original object, and is thus a covenient method of extracting detailed missingness information on the entire network. The network returned by
is.na is guaranteed to have the same base network attributes (directedness, loopness, hypergraphicity, multiplexity, and bipartite constraint) as the original network object, but no other information is copied; note too that edge IDs are not preserved by this process (although adjacency obviously is). Since the resulting object is a
network, standard coercion, print/summary, and other methods can be applied to it in the usual fashion.
It should be borne in mind that “missingness” in the sense used here reflects the assertion that an edge's presence or absence is unknown, not that said edge is known not to be present. Thus, the
na count for an empty graph is properly 0, since all edges are known to be absent. Edges can be flagged as missing by setting their
na attribute to
set.edge.attribute, or by appropriate use of the network assignment operators; see below for an example of the latter.
is.na(x) returns a network object, and
network.naedgecount(x) returns the number of missing edges.
Carter T. Butts [email protected]
Butts, C. T. (2008). “network: a Package for Managing Relational Data in R.” Journal of Statistical Software, 24(2). http://www.jstatsoft.org/v24/i02/
1 2 3 4 5 6 7 8 9 10 11
#Create an empty network with no missing data g<-network.initialize(5) g[,] #No edges present.... network.naedgecount(g)==0 #Edges not present are not "missing"! #Now, add some missing edges g[1,,add.edges=TRUE]<-NA #Establish that 1's ties are unknown g[,] #Observe the missing elements is.na(g) #Observe in network form network.naedgecount(g)==4 #These elements do count! network.edgecount(is.na(g)) #Same as above
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.