Learn R Programming

NetComp (version 1.6)

netClass: Network from Class List

Description

Returns an unweighted adjacency matrix with a '1' where observations are from the same class, '0' if from different classes based on a vector of class assingments.

Usage

netClass(x, labels=NULL)

Arguments

x
Numeric vector containing the class/cluster assignments
labels
Optional. Vector of labels for the individual observations

Value

A square matrix is returned with the number of rows, columns equal to the length of x and in the same order. If lables is supplied, they will be used as the row/column names.

Details

Used for converting class/community assingments into an adjacency matrix.

See Also

hclust{cutree}

Examples

Run this code
 #using the USArrest dataset
 arrestCor<-cor(t(USArrests))
 tree<-cutree(hclust(as.dist(1-arrestCor), method='ward'), k=10)
 netClass(tree, labels=colnames(arrestCor))
 

Run the code above in your browser using DataLab