====== Code Rnet 2 ======
===== Iris data =====
k.neighbor2Net <-
# stores network of first k neighbors for
# dissimilarity matrix d to file fnet in Pajek format.
function(fnet,d,k){
net <- file(fnet,"w")
n <- nrow(d); rn <- rownames(d)
cat("*vertices",n,"\n",file=net)
for (i in 1:n) cat(i," \"",rn[i],"\"\n",sep="",file=net)
cat("*arcs\n",file=net)
for (i in 1:n) for (j in order(d[i,])[1:k+1]) {
cat(i,j,d[i,j],"\n",file=net)
}
close(net)
}
data(iris)
ir <- scale(iris)
rownames(ir) <- paste(substr(iris[,5],1,2),1:nrow(iris),sep="")
k.neighbor2Net("iris5.net",as.matrix(dist(ir)),5)
===== Edinburgh associative thesaurus =====
-----------------------------------------------------------------------
The following vectors read:
v1 : All Degree of N2 (23219)
v2 : Input Degree of N2 (23219)
v3 : Output Degree of N2 (23219)
-----------------------------------------------------------------------
> t1 <- table(v1); t2 <- table(v2); t3 <- table(v3)
> x1 <- as.numeric(names(t1)); x2 <- as.numeric(names(t2)); x3 <- as.numeric(names(t3))
> y1 <- as.vector(t1); y2 <- as.vector(t2); y3 <- as.vector(t3)
> plot(x1,y1,log='xy',pch=16,cex=0.7,main="alldegree distribution in eatSR")
> points(x2,y2,pch=16,cex=0.7,col="blue")
> points(x3,y3,pch=16,cex=0.7,col="red")
{{ru:hse:rnet18:pic:eatsr.png}}
\\
[[ru:hse:rnet|Rnet]]