====== R tests ====== ===== Slices ===== > MS <- MN$links[MN$links$link.Y==3,] > head(MS) link.S link.T link.R link.Y w 17470 1 1 4 3 2 17471 1 1 9 3 4 17472 1 1 11 3 3 17473 1 2 4 3 7 17474 1 2 11 3 1 17475 1 3 3 3 5 > MSS <- MS[-c(4)] > head(MSS) link.S link.T link.R w 17470 1 1 4 2 17471 1 1 9 4 17472 1 1 11 3 17473 1 2 4 7 17474 1 2 11 1 17475 1 3 3 5 ===== Reordering ways ===== > head(MN$links) link.S link.T link.R link.Y w 1 1 1 4 1 4 2 1 1 5 1 1 3 1 1 9 1 1 4 1 1 11 1 1 5 1 2 4 1 11 6 1 3 3 1 1 > head(MN$links[c(3,2,1,4)]) link.R link.T link.S link.Y 1 4 1 1 1 2 5 1 1 1 3 9 1 1 1 4 11 1 1 1 5 4 2 1 1 6 3 3 1 1 > ===== Ordering links ===== > n <- length(s) > n [1] 37205 > per <- sample(1:n,n) > Mu <- MN$links > Mp <- Mu[per, ] > head(Mp) link.S link.T link.R link.Y w 24047 76 66 9 3 1 17528 1 54 11 3 2 4872 59 20 11 1 6 19689 24 35 3 3 1 17681 3 6 3 3 8 35584 91 67 9 4 6 > Mo <- Mp[order(Mp$link.S,Mp$link.T,Mp$link.R,Mp$link.Y), ] > head(Mo) link.S link.T link.R link.Y w 1 1 1 4 1 4 8868 1 1 4 2 6 17470 1 1 4 3 2 26763 1 1 4 4 3 2 1 1 5 1 1 26764 1 1 5 4 1 > ===== Flattening the way link.R ===== * https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/aggregate * https://www.w3schools.com/r/r_data_frames.asp * https://datascienceplus.com/aggregate-data-frame-r * https://stackoverflow.com/questions/45699992/how-to-aggregate-data-in-data-frame-in-r * https://www.r-bloggers.com/2018/07/how-to-aggregate-data-in-r/ Examples of aggregation functions are sum, mean, sd, median, average, min, max, length, etc. User can provide his own aggregation function. > MNr = aggregate(Mo$w, + by = list(Mo$link.S, Mo$link.T, Mo$link.Y), + FUN = sum) > str(MNr) 'data.frame': 15019 obs. of 4 variables: $ Group.1: int 1 2 4 6 7 8 9 10 12 13 ... $ Group.2: int 1 1 1 1 1 1 1 1 1 1 ... $ Group.3: int 1 1 1 1 1 1 1 1 1 1 ... $ x : int 7 13 2 1 1 3 2 8 9 1 ... > colnames(MNr) <- c("link.S","link.T","link.Y","w") > str(MNr) 'data.frame': 15019 obs. of 4 variables: $ link.S: int 1 2 4 6 7 8 9 10 12 13 ... $ link.T: int 1 1 1 1 1 1 1 1 1 1 ... $ link.Y: int 1 1 1 1 1 1 1 1 1 1 ... $ w : int 7 13 2 1 1 3 2 8 9 1 ... Check > L <- c() > for(i in 1:nrow(Mo)) if((Mo$link.S[i]==1)&&(Mo$link.T[i]==1)&&(Mo$link.Y[i]==1)) L <- c(L,i) > L [1] 1 5 8 13 > Mo[L,] link.S link.T link.R link.Y w 1 1 1 4 1 4 2 1 1 5 1 1 3 1 1 9 1 1 4 1 1 11 1 1 > L <- c() > for(i in 1:nrow(Mo)) if((Mo$link.S[i]==2)&&(Mo$link.T[i]==1)&&(Mo$link.Y[i]==1)) L <- c(L,i) > L [1] 537 541 544 547 553 > Mo[L,] link.S link.T link.R link.Y w 119 2 1 4 1 3 120 2 1 5 1 1 121 2 1 8 1 1 122 2 1 9 1 2 123 2 1 11 1 6 ===== Flattening the ways link.R and link.Y ===== > MNry = aggregate(Mo$w, + by = list(Mo$link.S, Mo$link.T), + FUN = sum) > str(MNry) 'data.frame': 5536 obs. of 3 variables: $ Group.1: int 1 2 3 4 5 6 7 8 9 10 ... $ Group.2: int 1 1 1 1 1 1 1 1 1 1 ... $ x : int 41 54 17 18 15 4 12 12 12 33 ... > colnames(MNry) <- c("link.S","link.T","w") > str(MNry) 'data.frame': 5536 obs. of 3 variables: $ link.S: int 1 2 3 4 5 6 7 8 9 10 ... $ link.T: int 1 1 1 1 1 1 1 1 1 1 ... $ w : int 41 54 17 18 15 4 12 12 12 33 ... The obtained data frame determines a two-mode network. We export it in Pajek format. > source("https://raw.githubusercontent.com/bavla/Rnet/master/R/Pajek.R") > S <- MN$nodes$prov$ID[MNry$link.S] > T <- MN$nodes$univ$ID[MNry$link.T] > uvrwt2net(S,T,w=MNry$w,Net="genovaRY.net",twomode=TRUE) ===== Join ways univ and prog ===== > S <- factor(s) > Nu <- MN$nodes[["univ"]]$ID > Nv <- MN$nodes[["prog"]]$ID > U <-Nu[MN$links$link.T] > V <-Nv[MN$links$link.R] > UV <- paste(U,V,sep="÷") > head(UV) [1] "Bicocca÷Business, administration and law" [2] "Bicocca÷Education" [3] "Bicocca÷Natural sciences, mathematics and statistics" [4] "Bicocca÷Social sciences, journalism and information" [5] "Bocconi÷Business, administration and law" [6] "Cà Foscari÷Arts and humanities" > UP <- factor(UV) > length(levels(UP)) [1] 493 > data <- list(title="Student mobility data in Italian universities 2008, 2011, 2014, 2017", + by=c("VG Genova","G Giordano","G Ragozini","MP Vitale"), + network="join univ+prog", + creator="V. Batagelj", date=date(), + waynames=list(prov="province",unpr="university+programme",year="year"), + nodes=list(prov=data.frame(ID=SN),unpr=data.frame(ID=levels(UP)),year=data.frame(ID=YN)), + links=data.frame(link=cbind(S,UP,Y),w=w)) > write(toJSON(data),"genovaUP.json") > uvrwt2net(s,UV,w=w,t=p,Net="genovaUP.net",twomode=TRUE) > > MUP <- fromJSON("genovaUP.json") > str(MUP) List of 8 $ title : chr "Student mobility data in Italian universities 2008, 2011, 2014, 2017" $ by : chr [1:4] "VG Genova" "G Giordano" "G Ragozini" "MP Vitale" $ network : chr "join univ+prog" $ creator : chr "V. Batagelj" $ date : chr "Mon Nov 7 16:42:28 2022" $ waynames:List of 3 ..$ prov: chr "province" ..$ unpr: chr "university+programme" ..$ year: chr "year" $ nodes :List of 3 ..$ prov:'data.frame': 107 obs. of 1 variable: .. ..$ ID: chr [1:107] "AG" "AL" "AN" "AO" ... ..$ unpr:'data.frame': 493 obs. of 1 variable: .. ..$ ID: chr [1:493] "Bicocca÷Business, administration and law" "Bicocca÷Education" "Bicocca÷Health and welfare" ... ..$ year:'data.frame': 4 obs. of 1 variable: .. ..$ ID: chr [1:4] "2008" "2011" "2014" "2017" $ links :'data.frame': 37205 obs. of 4 variables: ..$ link.S : int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ link.UP: int [1:37205] 1 2 5 7 8 10 17 18 20 22 ... ..$ link.Y : int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : int [1:37205] 4 1 1 1 11 1 1 1 1 1 ... ===== Projection of the year 2008 to prov ===== > MT <- MN$links[c(3,2,1,4,5)] > M1 <- MT[MT$link.Y==1,][c(1:3,5)] > MP <- M1[order(M1$link.R,M1$link.T,M1$link.S), ] > I <- c(1) > for(i in 2:nrow(MP)) if(!all(MP[i-1,1:2]==MP[i,1:2])) I <- c(I,i) > I <- c(I,nrow(MP)+1) > Co <- matrix(0,nrow=nS,ncol=nS) > colnames(Co) <- rownames(Co) <- MN$nodes$prov$ID > for(i in 1:(length(I)-1)){ + i1 <- I[i]; i2 <- I[i+1]-1 + for(j in i1:i2) { + u <- MP$link.S[j] + for(k in j:i2){ + v <- MP$link.S[k] + Co[u,v] <- Co[u,v] + MP$w[j] * MP$w[k] + } + } + } > Cot <- t(Co); diag(Cot) <- 0; Co <- Co + Cot > matrix2net(Co,Net="GenovaCo2008.net") > Co[1:5,1:15] AG AL AN AO AP AQ AR AT AV BA BG BI BL BN BO AG 1803 1517 1078 1075 734 724 423 220 1081 2186 408 427 369 978 622 AL 1517 28188 854 668 380 398 563 1267 461 1956 380 1281 250 467 720 AN 1078 854 5112 728 2048 1471 1826 209 1676 3384 1045 370 674 1307 817 AO 1075 668 728 8542 314 396 267 160 715 1780 700 270 244 605 440 AP 734 380 2048 314 2697 1822 1015 104 2177 2877 413 156 345 2148 446 Compute the Salton index, apply clustering and draw the dendrogram. > Sal <- Co; diag(Sal) <- 1 > n = nrow(Sal) > for(u in 1:(n-1)) for(v in (u+1):n) Sal[v,u] <- Sal[u,v] <- Co[u,v]/sqrt(Co[u,u]*Co[v,v]) > matrix2net(Sal,Net="SaltonProv2018.net") > D <- as.dist(1-Sal) > t <- hclust(D,method="ward.D") > plot(t,hang=-1,cex=1,main="Provinces 2008 / Ward") {{vlado:work:pics:genovaprov2008dendro.png?1200}} ===== Recoding ===== > w <- c(3,0,6,1,5,17,33,10) > b <- c(1,5,10,20,Inf) > w1 <- rep(0,length(w)) > for(i in 1:length(w)){ + j <- 0 + while(w[i]>=b[j+1]) j <- j+1 + w1[i] <- j + } > b [1] 1 5 10 20 Inf > rbind(w,w1) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] w 3 0 6 1 5 17 33 10 w1 1 0 2 1 2 3 4 3 > > w <- MN$links$w > length(w) [1] 37205 > table(w) w 1 2 3 4 5 6 7 8 9 10 11 12 13 16992 6623 3303 2080 1446 1034 853 621 503 440 341 303 255 14 15 16 17 18 19 20 21 22 23 24 25 26 218 182 193 136 149 106 97 79 88 85 71 74 64 27 28 29 30 31 32 33 34 35 36 37 38 39 46 44 47 42 41 32 37 39 26 19 24 17 26 40 41 42 43 44 45 46 47 48 49 50 51 52 23 24 18 20 18 9 11 14 16 10 13 11 9 53 54 55 56 57 58 59 60 61 62 63 64 65 11 7 4 11 5 6 3 13 6 2 6 6 8 66 67 68 69 70 71 72 73 75 76 77 78 79 1 5 5 8 5 7 4 4 6 5 4 3 4 80 81 82 83 84 85 86 87 88 89 90 92 95 5 5 5 2 3 3 3 2 2 1 2 1 4 97 98 99 104 105 106 107 108 109 115 117 118 119 1 1 1 1 2 1 3 2 1 2 2 1 1 122 123 127 133 140 141 144 145 146 147 148 149 157 1 1 1 2 1 1 1 1 1 2 1 1 1 161 164 165 168 169 178 182 190 214 219 326 1 1 2 1 1 1 1 1 1 1 1 > b <- c(1,5,10,20,Inf) > w1 <- rep(0,length(w)) > for(i in 1:length(w)){ + j <- 0 + while(w[i]>=b[j+1]) j <- j+1 + w1[i] <- j + } > > table(w1) w1 1 2 3 4 28998 4457 2323 1427 ===== Clusters aggregation (blockmodeling) ===== We would like to aggregate data about provinces to the level of regions. The partition of regions into provinces is available at [[https://en.wikipedia.org/wiki/Provinces_of_Italy|Wikipedia]]. The problem is that the ordering of provinces is not the same in both data sets. [[https://raw.githubusercontent.com/bavla/ibm3m/master/data/provinces.csv|provinces.csv]] data from Wikipedia. ==== Extending the data set with data about provinces ==== > P <- read.table("provinces.csv",skip=2,header=TRUE,sep=";",stringsAsFactors=FALSE) > NS <- as.vector(MN$nodes$prov$ID) > Code <- as.vector(trimws(P$Code)) > p <- match(NS,Code) > p [1] 1 2 3 4 6 42 5 7 8 9 13 14 11 12 15 17 16 10 [19] 89 18 20 21 24 19 29 25 27 26 22 23 30 35 32 34 33 31 [37] 36 37 38 39 40 41 28 46 45 47 48 44 49 57 50 54 55 51 [55] 56 52 53 59 NA 60 61 63 69 62 68 66 70 72 74 64 71 67 [73] 65 73 76 77 78 75 79 81 80 82 83 86 87 43 90 84 88 85 [91] 91 92 95 98 94 93 97 96 99 100 102 103 101 106 104 107 105 > Code[1:12] [1] "AG" "AL" "AN" "AO" "AR" "AP" "AT" "AV" "BA" "BT" "BL" "BN" > NS[1:12] [1] "AG" "AL" "AN" "AO" "AP" "AQ" "AR" "AT" "AV" "BA" "BG" "BI" > Code[40:52] [1] "IM" "IS" "AQ" "SP" "LT" "LE" "LC" "LI" "LO" "LU" "MC" "MN" "MS" > Code[p[5]] [1] "AP" > Code[p[6]] [1] "AQ" > > reg <- factor(NR) > Reg <- trimws(P$Region[p]) > cbind(NS,Reg)[1:10,] NS Reg [1,] "AG" "Sicily" [2,] "AL" "Piedmont" [3,] "AN" "Marche" [4,] "AO" "Aosta Valley" [5,] "AP" "Marche" [6,] "AQ" "Abruzzo" [7,] "AR" "Tuscany" [8,] "AT" "Piedmont" [9,] "AV" "Campania" [10,] "BA" "Apulia" > reg <- factor(Reg) > NR <- levels(reg) > NR [1] "Abruzzo" "Aosta Valley" "Apulia" [4] "Basilicata" "Calabria" "Campania" [7] "Emilia-Romagna" "Friuli-Venezia Giulia" "Lazio" [10] "Liguria" "Lombardy" "Marche" [13] "Molise" "Piedmont" "Sardinia" [16] "Sicily" "Trentino-South Tyrol" "Tuscany" [19] "Umbria" "Veneto" There is a NA in p. Let's see where NS and Code differ > setdiff(NS,Code) [1] "NP" > setdiff(Code,NS) [1] "NA" It seems that a different code is used for the province of Naples (Napoli). ==== Again, from scratch ==== > wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/data" > setwd(wdir) > library(jsonlite) > source("https://raw.githubusercontent.com/bavla/Rnet/master/R/Pajek.R") > MN <- fromJSON("genovaMN.json") > str(MN) > data <- list(format="MWnets",info=MN[1:4],ways=MN$waynames,nodes=MN$nodes,links=MN$links) > str(data) List of 5 $ format: chr "MWnets" $ info :List of 4 ..$ title : chr "Student mobility data in Italian universities 2008, 2011, 2014, 2017" ..$ by : chr [1:4] "VG Genova" "G Giordano" "G Ragozini" "MP Vitale" ..$ creator: chr "V. Batagelj" ..$ date : chr "Sun Nov 6 22:31:11 2022" $ ways :List of 4 ..$ prov: chr "province" ..$ univ: chr "university" ..$ prog: chr "programme" ..$ year: chr "year" $ nodes :List of 4 ..$ prov:'data.frame': 107 obs. of 1 variable: .. ..$ ID: chr [1:107] "AG" "AL" "AN" "AO" ... ..$ univ:'data.frame': 79 obs. of 1 variable: .. ..$ ID: chr [1:79] "Bicocca" "Bocconi" "Cà Foscari" "Campus Biomedico" ... ..$ prog:'data.frame': 11 obs. of 1 variable: .. ..$ ID: chr [1:11] "?" "Agriculture, forestry, fisheries and veterinary" "Arts and humanities" ... ..$ year:'data.frame': 4 obs. of 1 variable: .. ..$ ID: chr [1:4] "2008" "2011" "2014" "2017" $ links :'data.frame': 37205 obs. of 5 variables: ..$ link.S: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ link.T: int [1:37205] 1 1 1 1 2 3 4 5 5 5 ... ..$ link.R: int [1:37205] 4 5 9 11 4 3 9 3 5 9 ... ..$ link.Y: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : int [1:37205] 4 1 1 1 11 1 1 1 1 1 ... We would like to add to the data set the short names of universities and programs. I prepared them as assignments in TextPad. We would also like to add to provinces the data from Wikipedia. > Ushort <- c( + "Bicocca" + , "Bocconi" + , "Foscari" ... > Pshort <- c("?", "AFFV", "AH", "BAL", "Edu", "EMC", "HW", "ICT", "NsMS", "Serv", "SsJI") > R <- data$nodes$prog > R$short <- Pshort > head(R) > data$nodes$prog <- R > str(data) > U <- data$nodes$univ > U$short <- Ushort > head(U) > data$nodes$univ <- U > str(data) > P <- read.table("provinces.csv",skip=2,header=TRUE,sep=";",stringsAsFactors=FALSE) > NS <- as.vector(MN$nodes$prov$ID) > Code <- as.vector(trimws(P$Code)) > NS [1] "AG" "AL" "AN" "AO" "AP" "AQ" "AR" "AT" "AV" "BA" "BG" "BI" "BL" "BN" "BO" "BR" "BS" "BT" [19] "BZ" "CA" "CB" "CE" "CH" "CL" "CN" "CO" "CR" "CS" "CT" "CZ" "EN" "FC" "FE" "FG" "FI" "FM" [37] "FR" "GE" "GO" "GR" "IM" "IS" "KR" "LC" "LE" "LI" "LO" "LT" "LU" "MB" "MC" "ME" "MI" "MN" [55] "MO" "MS" "MT" "NO" "NP" "NU" "OR" "PA" "PC" "PD" "PE" "PG" "PI" "PN" "PO" "PR" "PT" "PU" [73] "PV" "PZ" "RA" "RC" "RE" "RG" "RI" "RM" "RN" "RO" "SA" "SI" "SO" "SP" "SR" "SS" "SU" "SV" [91] "TA" "TE" "TN" "TO" "TP" "TR" "TS" "TV" "UD" "VA" "VB" "VC" "VE" "VI" "VR" "VT" "VV" > Code [1] "AG" "AL" "AN" "AO" "AR" "AP" "AT" "AV" "BA" "BT" "BL" "BN" "BG" "BI" "BO" "BS" "BR" "CA" [19] "CL" "CB" "CE" "CT" "CZ" "CH" "CO" "CS" "CR" "KR" "CN" "EN" "FM" "FE" "FI" "FG" "FC" "FR" [37] "GE" "GO" "GR" "IM" "IS" "AQ" "SP" "LT" "LE" "LC" "LI" "LO" "LU" "MC" "MN" "MS" "MT" "ME" [55] "MI" "MO" "MB" "NA" "NO" "NU" "OR" "PD" "PA" "PR" "PV" "PG" "PU" "PE" "PC" "PI" "PT" "PN" [73] "PZ" "PO" "RG" "RA" "RC" "RE" "RI" "RN" "RM" "RO" "SA" "SS" "SV" "SI" "SO" "SU" "BZ" "SR" [91] "TA" "TE" "TR" "TP" "TN" "TV" "TS" "TO" "UD" "VA" "VE" "VB" "VC" "VR" "VV" "VI" "VT" > Code[58] [1] "NA" > Code[58] <- "NP" > P$Code[58] <- "NP" > p <- match(NS,Code) > Q <- P[p,] > R <- data$nodes$prov > R$type <- Q$Type > R$province <- Q$Province > R$capital <- Q$Capital > R$region <- Q$Region > R$macreg <- Q$Macroregion > R$population <- as.numeric(gsub(",","",Q$Population2021)) > R$area <- as.numeric(gsub(",","",Q$AreaKm2)) > head(R) > data$nodes$prov <- R > str(data) > str(data) List of 5 $ format: chr "MWnets" $ info :List of 4 ..$ title : chr "Student mobility data in Italian universities 2008, 2011, 2014, 2017" ..$ by : chr [1:4] "VG Genova" "G Giordano" "G Ragozini" "MP Vitale" ..$ creator: chr "V. Batagelj" ..$ date : chr "Sun Nov 6 22:31:11 2022" $ ways :List of 4 ..$ prov: chr "province" ..$ univ: chr "university" ..$ prog: chr "programme" ..$ year: chr "year" $ nodes :List of 4 ..$ prov:'data.frame': 107 obs. of 8 variables: .. ..$ ID : chr [1:107] "AG" "AL" "AN" "AO" ... .. ..$ type : chr [1:107] "F" "O" "O" "D" ... .. ..$ province : chr [1:107] "Agrigento" "Alessandria" "Ancona" "Aosta" ... .. ..$ capital : chr [1:107] "Agrigento" "Alessandria" "Ancona" "Aosta" ... .. ..$ region : chr [1:107] "Sicily" "Piedmont" "Marche" "Aosta Valley" ... .. ..$ macreg : chr [1:107] "Insular" "North-West" "Centre" "North-West" ... .. ..$ population: num [1:107] 416181 409392 464419 124089 203425 ... .. ..$ area : num [1:107] 3053 3559 1963 3261 1228 ... ..$ univ:'data.frame': 79 obs. of 2 variables: .. ..$ ID : chr [1:79] "Bicocca" "Bocconi" "Cà Foscari" "Campus Biomedico" ... .. ..$ short: chr [1:79] "Bicocca" "Bocconi" "Foscari" "Biomedico" ... ..$ prog:'data.frame': 11 obs. of 2 variables: .. ..$ ID : chr [1:11] "?" "Agriculture, forestry, fisheries and veterinary" "Arts and humanities" ... .. ..$ short: chr [1:11] "?" "AFFV" "AH" "BAL" ... ..$ year:'data.frame': 4 obs. of 1 variable: .. ..$ ID: chr [1:4] "2008" "2011" "2014" "2017" $ links :'data.frame': 37205 obs. of 5 variables: ..$ link.S: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ link.T: int [1:37205] 1 1 1 1 2 3 4 5 5 5 ... ..$ link.R: int [1:37205] 4 5 9 11 4 3 9 3 5 9 ... ..$ link.Y: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : int [1:37205] 4 1 1 1 11 1 1 1 1 1 ... > write(toJSON(data),"genovaExt.json") ==== students.json ==== I decided to simplify the structure of a multiway network description - use the way names also for initial link columns. I also decided to use short node names as IDs and old IDs as long node names. > wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/data" > setwd(wdir) > library(jsonlite) > source("https://raw.githubusercontent.com/bavla/Rnet/master/R/Pajek.R") > MN <- fromJSON("genovaExt.json") > nodes <- MN$nodes > nodes$univ <- data.frame(ID=nodes$univ$short,long=nodes$univ$ID) > nodes$prog <- data.frame(ID=nodes$prog$short,long=nodes$prog$ID) > nodes$prog$ID[1] <- "Q" > data <- list(format="MWnets",info=c(network="students",MN$info), + ways=MN$ways,nodes=nodes, + links=data.frame(prov=MN$links$link.S,univ=MN$links$link.T, + prog=MN$links$link.R,year=MN$links$link.Y,w=MN$links$w)) > str(data) List of 5 $ format: chr "MWnets" $ info :List of 5 ..$ network: chr "students" ..$ title : chr "Student mobility data in Italian universities 2008, 2011, 2014, 2017" ..$ by : chr [1:4] "VG Genova" "G Giordano" "G Ragozini" "MP Vitale" ..$ creator: chr "V. Batagelj" ..$ date : chr "Sun Nov 6 22:31:11 2022" $ ways :List of 4 ..$ prov: chr "province" ..$ univ: chr "university" ..$ prog: chr "programme" ..$ year: chr "year" $ nodes :List of 4 ..$ prov:'data.frame': 107 obs. of 8 variables: .. ..$ ID : chr [1:107] "AG" "AL" "AN" "AO" ... .. ..$ type : chr [1:107] "F" "O" "O" "D" ... .. ..$ province : chr [1:107] "Agrigento" "Alessandria" "Ancona" "Aosta" ... .. ..$ capital : chr [1:107] "Agrigento" "Alessandria" "Ancona" "Aosta" ... .. ..$ region : chr [1:107] "Sicily" "Piedmont" "Marche" "Aosta Valley" ... .. ..$ macreg : chr [1:107] "Insular" "North-West" "Centre" "North-West" ... .. ..$ population: int [1:107] 416181 409392 464419 124089 203425 290811 336501 209390 402929 1230158 ... .. ..$ area : num [1:107] 3053 3559 1963 3261 1228 ... ..$ univ:'data.frame': 79 obs. of 2 variables: .. ..$ ID : chr [1:79] "Bicocca" "Bocconi" "Foscari" "Biomedico" ... .. ..$ long: chr [1:79] "Bicocca" "Bocconi" "Cà Foscari" "Campus Biomedico" ... ..$ prog:'data.frame': 11 obs. of 2 variables: .. ..$ ID : chr [1:11] "Q" "AFFV" "AH" "BAL" ... .. ..$ long: chr [1:11] "?" "Agriculture, forestry, fisheries and veterinary" "Arts and humanities" "Business, administration and law" ... ..$ year:'data.frame': 4 obs. of 1 variable: .. ..$ ID: chr [1:4] "2008" "2011" "2014" "2017" $ links :'data.frame': 37205 obs. of 5 variables: ..$ prov: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ univ: int [1:37205] 1 1 1 1 2 3 4 5 5 5 ... ..$ prog: int [1:37205] 4 5 9 11 4 3 9 3 5 9 ... ..$ year: int [1:37205] 1 1 1 1 1 1 1 1 1 1 ... ..$ w : int [1:37205] 4 1 1 1 11 1 1 1 1 1 ... > write(toJSON(data),"students.json")