Learn R Programming

network (version 1.19.0)

missing.edges: Identifying and Counting Missing Edges in a Network Object

Description

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.

Usage

# S3 method for network
is.na(x)

network.naedgecount(x, ...)

Value

is.na(x) returns a network object, and network.naedgecount(x) returns the number of missing edges.

Arguments

x

an object of class network

...

additional arguments, not used

Author

Carter T. Butts buttsc@uci.edu

Details

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 na==TRUE. The 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 TRUE using set.edge.attribute, or by appropriate use of the network assignment operators; see below for an example of the latter.

References

Butts, C. T. (2008). “network: a Package for Managing Relational Data in R.” Journal of Statistical Software, 24(2). tools:::Rd_expr_doi("10.18637/jss.v024.i02")

See Also

network.edgecount, get.network.attribute, is.adjacent, is.na

Examples

Run this code

#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


Run the code above in your browser using DataLab