Learn R Programming

qdap (version 1.3.5)

adjacency_matrix: Takes a Matrix and Generates an Adjacency Matrix

Description

Takes a matrix (wfm) or termco object and generates an adjacency matrix for use with the http://igraph.sourceforge.net/{igraph} package.

Usage

adjacency_matrix(matrix.obj)

adjmat(matrix.obj)

Arguments

matrix.obj
A matrix object, preferably, of the class "termco" generated from termco, termco_d or termco_c

Value

  • Returns list:
  • booleanA Boolean matrix
  • adjacencyAn adjacency matrix. Diagonals are the total (sum) number of occurrences a variable had
  • sharedAn adjacency matrix with no diagonal and the upper triangle replaced with NA
  • sumThe diagonal of the adjacency matrix; the total (sum) number of occurrences a variable had

See Also

dist

Examples

Run this code
words <- c(" you", " the", "it", "oo")
Terms <- with(DATA, termco(state, list(sex, adult), words))
Terms
adjacency_matrix(Terms)

wordLIST <- c(" montague", " capulet", " court", " marry")
raj.termco <- with(raj.act.1, termco(dialogue, person, wordLIST))
raj.adjmat <- adjmat(raj.termco)
names(raj.adjmat)  #see what's available from the adjacency_matrix object
library(igraph)
g <- graph.adjacency(raj.adjmat$adjacency, weighted=TRUE, mode ="undirected")
g <- simplify(g)
V(g)$label <- V(g)$name
V(g)$degree <- degree(g)
plot(g, layout=layout.auto(g))

Run the code above in your browser using DataLab