# convert the Sampson's monks network into a native ernm network
data(samplike)
sampnet <- as.BinaryNet(samplike)
sampnet
# get the number of nodes and edges in the network
sampnet$size()
sampnet$nEdges()
# Extract and assign vertex attributes
sampnet[["group"]]
sampnet[["newvar"]] <- rnorm(18)
sampnet[["newvar"]]
# get the edge matrix between the first 5 vertices
sampnet[1:5,1:5]
# add an edge 2 --> 3
sampnet[2,3] <- TRUE
# Make the dyad 4 --> 1 missing
sampnet[4,1] <- NA
sampnet[1:5,1:5]
# get the in and out degrees for each vertex
sampnet$inDegree(1:18)
sampnet$outDegree(1:18)
Run the code above in your browser using DataLab