using graph.adjacency() in R

前端 未结 2 1724
时光说笑
时光说笑 2020-12-16 20:32

I have a sample code in R as follows:

library(igraph)
rm(list=ls())
dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=T) # read .csv file
m=as.m         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 21:10

    Just a small working example below, much clearer than CSV input.

    library('igraph');
    adjm1<-matrix(sample(0:1,100,replace=TRUE,prob=c(0.9,01)),nc=10); 
    g1<-graph.adjacency(adjm1); 
    plot(g1)
    

    enter image description here

    P.s. ?graph.adjacency has a lot of good examples (remember to run library('igraph')).

    Related threads

    1. Creating co-occurrence matrix
    2. Co-occurrence matrix using SAC?

提交回复
热议问题