> load("./multi/polit.RData") > dn <- attr(P,"dimnames") > info <- list(network="Politicians", + title="Dissimilarity ratings of Second World War politicians by two subjects", + by="B.S. Everitt", + ref="B.S. Everitt: Introduction to optimization methods and their application in statistics. Chapman and Hall, London, 1987, p. 72.", + href="http://vladowiki.fmf.uni-lj.si/doku.php?id=notes:da:clu:mul", + creator="V. Batagelj", + date=date() ) > ways=list(P1="first politician",P2="second politician",S="subjects") > nodes=list(P1=data.frame(ID=dn[[2]]),P2=data.frame(ID=dn[[3]]),S=data.frame(ID=dn[[1]])) > M <- matrix(0,nrow=2*12*12,ncol=4); s <- 0 > for(i in 1:2) for(j in 1:12) for(k in 1:12) {s <- s+1; M[s,] <- c(j,k,i,P[i,j,k])} > links=data.frame(P1=M[,1],P2=M[,2],S=M[,3],w=M[,4]) > Mpol <- list(format="MWnets",info=info,ways=ways,nodes=nodes,links=links,data=list()) > write(toJSON(Mpol),"./multi/polit.json") > str(Mpol) List of 6 $ format: chr "MWnets" $ info :List of 7 ..$ network: chr "Politicians" ..$ title : chr "Dissimilarity ratings of Second World War politicians by two subjects" ..$ by : chr "B.S. Everitt" ..$ ref : chr "B.S. Everitt: Introduction to optimization methods and their application in statistics. Chapman and Hall, London, 1987, p. 72." ..$ href : chr "http://vladowiki.fmf.uni-lj.si/doku.php?id=notes:da:clu:mul" ..$ creator: chr "V. Batagelj" ..$ date : chr "Thu Dec 1 16:02:29 2022" $ ways :List of 3 ..$ P1: chr "first politician" ..$ P2: chr "second politician" ..$ S : chr "subjects" $ nodes :List of 3 ..$ P1:'data.frame': 12 obs. of 1 variable: .. ..$ ID: chr [1:12] "Hitler" "Mussolini" "Churchill" "Eisenhower" ... ..$ P2:'data.frame': 12 obs. of 1 variable: .. ..$ ID: chr [1:12] "Hitler" "Mussolini" "Churchill" "Eisenhower" ... ..$ S :'data.frame': 2 obs. of 1 variable: .. ..$ ID: chr [1:2] "P1" "P2" $ links :'data.frame': 288 obs. of 4 variables: ..$ P1: num [1:288] 1 1 1 1 1 1 1 1 1 1 ... ..$ P2: num [1:288] 1 2 3 4 5 6 7 8 9 10 ... ..$ S : num [1:288] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : num [1:288] 0 2 7 8 5 9 2 6 8 8 ... $ data : list()
> load("./multi/kinship.RData") > dn <- attr(K,"dimnames") > info <- list(network="Kinship", + title="Rosenberg and Kim (1975) Kinship Terms", + by="S. Rosenberg and M. P. Kim", + ref=attr(K,"refs"), + href="http://vladowiki.fmf.uni-lj.si/doku.php?id=notes:da:clu:mul", + creator="V. Batagelj", + date=date() ) > ways=list(T1="first term",T2="second term",K="subjects") > nodes=list(T1=data.frame(ID=dn[[2]],IDen=attr(K,"labAN"),IDsi=attr(K,"labSI")), + T2=data.frame(ID=dn[[3]]),K=data.frame(ID=dn[[1]])) > M <- matrix(0,nrow=6*15*15,ncol=4); s <- 0 > for(i in 1:6) for(j in 1:15) for(k in 1:15) {s <- s+1; M[s,] <- c(j,k,i,K[i,j,k])} > links=data.frame(T1=M[,1],T2=M[,2],K=M[,3],w=M[,4]) > Mkin <- list(format="MWnets",info=info,ways=ways,nodes=nodes,links=links,data=list()) > write(toJSON(Mkin),"./multi/kinship.json") > str(Mkin) List of 6 $ format: chr "MWnets" $ info :List of 7 ..$ network: chr "Kinship" ..$ title : chr "Rosenberg and Kim (1975) Kinship Terms" ..$ by : chr "S. Rosenberg and M. P. Kim" ..$ ref : chr "S. Rosenberg and M. P. Kim (1975). The method of sorting as a data-gathering procedure in multivariate research"| __truncated__ ..$ href : chr "http://vladowiki.fmf.uni-lj.si/doku.php?id=notes:da:clu:mul" ..$ creator: chr "V. Batagelj" ..$ date : chr "Thu Dec 1 17:36:22 2022" $ ways :List of 3 ..$ T1: chr "first term" ..$ T2: chr "second term" ..$ K : chr "subjects" $ nodes :List of 3 ..$ T1:'data.frame': 15 obs. of 3 variables: .. ..$ ID : chr [1:15] "Aunt" "Brother" "Cousin" "Daughter" ... .. ..$ IDen: chr [1:15] "FCA:aunt" "MN*:brot" "*C*:cous" "FND:daug" ... .. ..$ IDsi: chr [1:15] "teta" "brat" "bra/sestri\xe8na" "h\xe8i" ... ..$ T2:'data.frame': 15 obs. of 1 variable: .. ..$ ID: chr [1:15] "Aunt" "Brother" "Cousin" "Daughter" ... ..$ K :'data.frame': 6 obs. of 1 variable: .. ..$ ID: chr [1:6] "K1" "K2" "K3" "K4" ... $ links :'data.frame': 1350 obs. of 4 variables: ..$ T1: num [1:1350] 1 1 1 1 1 1 1 1 1 1 ... ..$ T2: num [1:1350] 1 2 3 4 5 6 7 8 9 10 ... ..$ K : num [1:1350] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : num [1:1350] 0 79 56 36 76 34 76 36 77 33 ... $ data : list()
I manually replaced \xe8 with č in the file kinship.json.
> MK <- fromJSON("./multi/kinship.json") > str(MK)