- The first task is to load the required libraries:
library(statnet,quietly=TRUE)library(network,quietly=TRUE)
The purpose of specifying the option quietly=TRUE is that a lot of comments are printed to the console and we can offset that with this option. Operationally, it makes no difference whether we use this option or not.
- Next, we specify a matrix with four rows and columns, a square matrix as expected, which will be then used to set up a network:
netmat1 <- rbind(c(0,1,1,0), c(1,0,1,0), c(1,1,0,1), c(0,0,1,0))rownames(netmat1) <- c("A","B","C","D")colnames(netmat1) <- c("A","B","C","D")netmat1
- A consequence is the following output in the R console:
> netmat1A B C DA 0 1 1 0B 1 0 1 0C 1 1 0 1D 0 0 1 0
- The matrix ...