Skip to content

Instantly share code, notes, and snippets.

@pedroj
Created February 20, 2012 23:17
Show Gist options
  • Save pedroj/1872207 to your computer and use it in GitHub Desktop.
Save pedroj/1872207 to your computer and use it in GitHub Desktop.
Read network data
##############################################################################
### Read network data
# network
mont1<-read.paj("Monteverde.net",verbose=T)
nch1<-read.paj("nch.net",verbose=T)
hr1<-read.paj("hr.net",verbose=T)
# Initializing bipartite webs for library network
nch1<-network.initialize(dim(nch_lab)[1]+dim(nch_lab)[2],
bipartite=c(dim(nch_lab)[1]),directed=F)
nch1 <-network.bipartite(as.matrix(nch_lab),nch1)
hr1<-network.initialize(dim(hr_lab)[1]+dim(hr_lab)[2],
bipartite=c(dim(hr_lab)[1]),directed=F)
hr1<-network.bipartite(as.matrix(hr_lab),hr1)
### Plot ---------------------------------------------------------------------
par(mfrow=c(1,2))
plot.network(nch1,
usearrows=FALSE,jitter= T,
# mode= "circle",
# mode= "fruchtermanreingold",
mode= "kamadakawai",
label=network.vertex.names(nch1),displaylabels = T,
boxed.labels= F,label.pad=0,label.pos= 5,label.cex= 0.8,
vertex.col=c(rep(2,dim(nch_lab)[1]),rep(3,dim(nch_lab)[2])),vertex.cex= 2,
vertex.sides= c(rep(5,dim(nch_lab)[1]),rep(12,dim(nch_lab)[2])),
vertex.lty= 0,edge.lty=0.5,edge.col=8,label.lty=NULL,usecurve = F)
#-----------------------------------------------------------------------------
plot.network(hr1,
usearrows=FALSE,jitter= T,
# mode= "circle",
# mode= "fruchtermanreingold",
mode= "kamadakawai",
label=network.vertex.names(hr1),displaylabels = T,
boxed.labels= F,label.pad=0,label.pos= 5,label.cex= 0.8,
vertex.col=c(rep(2,dim(hr_lab)[1]),rep(3,dim(hr_lab)[2])),vertex.cex= 2,
vertex.sides= c(rep(5,dim(hr_lab)[1]),rep(12,dim(hr_lab)[2])),
vertex.lty= 0,edge.lty=0.5,edge.col=8,label.lty=NULL,usecurve = F)
#-----------------------------------------------------------------------------
#plot.network(nch1, attrname = NULL,
# coord = NULL, jitter = F,
# thresh = 0, usearrows = F, mode = "fruchtermanreingold",
# displayisolates = TRUE, interactive = F, xlab = NULL,
# ylab = NULL, xlim = NULL, ylim = NULL, pad = 0, label.pad = 0,
# displaylabels = T, boxed.labels = F, label.pos = 0,
# label.bg = "white", vertex.sides = 8, vertex.rot = 0,
# arrowhead.cex = 1, label.cex = 1, loop.cex = 1, vertex.cex = 2,
# edge.col = 1, label.col = 1,vertex.col =c(rep(2,36),rep(3,25)),
# label.border = 1,
# vertex.border = 1, edge.lty = 0.5, label.lty = NULL, vertex.lty = 0,
# edge.lwd = 0, label.lwd = par("lwd"), edge.len = 0.5,
# edge.curve = 0.1, edge.steps = 50, loop.steps = 20,
# object.scale = 0.01, uselen = FALSE, usecurve = FALSE,
# suppress.axes = TRUE, vertices.last = TRUE, new = TRUE,
# layout.par = NULL)
plot.sociomatrix(nch1)
dat <- as.sociomatrix.sna(as.matrix(acor))
a<-as.matrix(acor)
plot.sociomatrix(as.matrix(interv))
# Plot the matrices
par(mfrow=c(1,2))
heatmap(as.matrix(nch_lab),col=grey((32:0)/32),margins=c(15,15))
heatmap(as.matrix(hr_lab),col=grey((32:0)/32),margins=c(15,15))
heatmap(as.matrix(interv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment