The network from
https://github.com/marmello77/multilayer-networks
> wdir <- "C:/Users/vlado/DL/data/multi/multilayer/marmello77/data" > setwd(wdir) > N <- read.csv("net1links.txt",sep="\t") > head(N) animals plants weight layer 1 GueIng ByrSp 2 antagonistic 2 NecLas CamAda 20 antagonistic 3 PhiFre CecHol 1 antagonistic 4 CerSub CecPac 13 antagonistic 5 DidAur CecPac 6 antagonistic 6 PhiFre CecPac 1 antagonistic > an <- factor(N$animals); pl <- factor(N$plants); R <- factor(N$layer) > info <- list(network="marmello77", + by=c("Marco Mello","Renata Muylaert"), + title="Ecological multilayer network", + url=c("https://github.com/marmello77/multilayer-networks","https://doi.org/10.1111/oik.03825"), + creator="V. Batagelj",date=date()) > ways <- list(an="animal",pl="plant",R="relation") > nodes <- list(an=data.frame(ID=levels(an)),pl=data.frame(ID=levels(pl)), + R=data.frame(ID=levels(R))) > links <- data.frame(an=as.integer(an),pl=as.integer(pl), + R=as.integer(R),w=N$weight) > data <- list() > NM <- list(format="MWnets",info=info,ways=ways,nodes=nodes,links=links,data=data) > > str(NM) List of 6 $ format: chr "MWnets" $ info :List of 6 ..$ network: chr "marmello77" ..$ by : chr [1:2] "Marco Mello" "Renata Muylaert" ..$ title : chr "Ecological multilayer network" ..$ url : chr [1:2] "https://github.com/marmello77/multilayer-networks" "https://doi.org/10.1111/oik.03825" ..$ creator: chr "V. Batagelj" ..$ date : chr "Wed Jan 11 04:43:51 2023" $ ways :List of 3 ..$ an: chr "animal" ..$ pl: chr "plant" ..$ R : chr "relation" $ nodes :List of 3 ..$ an:'data.frame': 9 obs. of 1 variable: .. ..$ ID: chr [1:9] "CerSco" "CerSub" "DidAlb" "DidAur" ... ..$ pl:'data.frame': 34 obs. of 1 variable: .. ..$ ID: chr [1:34] "ByrSp" "CamAda" "CecGla" "CecHol" ... ..$ R :'data.frame': 2 obs. of 1 variable: .. ..$ ID: chr [1:2] "antagonistic" "mutualistic" $ links :'data.frame': 72 obs. of 4 variables: ..$ an: int [1:72] 5 7 9 2 4 9 2 4 7 1 ... ..$ pl: int [1:72] 1 2 4 5 5 5 3 3 6 7 ... ..$ R : int [1:72] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : int [1:72] 2 20 1 13 6 1 12 11 3 6 ... $ data : list() > write(toJSON(NM),"marmello77.json")