Lazega

Creating JSON file

> library(jsonlite)
> wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/R/test"
> setwd(wdir)
> a <- read.csv("triplet.dat",sep="",header=FALSE)
> I <- a$V1; J <- a$V2; K <- a$V3; labs <- paste('L',1:36,sep='')
> wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/data/lazega"
> setwd(wdir)
> b <- read.csv("ELattr.dat",sep="",header=FALSE)
> B <- b[1:36, ]
> colnames(B) <- c("seniority","status","gender","office","years","age","speciality","school")
> gen <- c("man","woman")[B$gender]
> ofi <- c("Boston","Hartford","Providence")[B$office]
> spe <- c("litigation","corporate")[B$speciality]
> sch <- c("harvard_yale","ucon","other")[B$school]
> C <- data.frame(ID=labs,seniority=B$seniority,gender=gen,office=ofi,years=B$years,age=B$age,speciality=spe,school=sch)
> head(C)
  ID seniority gender   office years age speciality       school
1 L1         1    man   Boston    31  64 litigation harvard_yale
2 L2         2    man   Boston    32  62  corporate harvard_yale
3 L3         3    man Hartford    13  67 litigation harvard_yale
4 L4         4    man   Boston    31  59  corporate        other
5 L5         5    man Hartford    31  59 litigation         ucon
6 L6         6    man Hartford    29  55 litigation harvard_yale
> data <- list(title="Lazega's Lawyers / 36 partners",
+   by=c("E Lazega"),
+   creator="V. Batagelj", date=date(), 
+   waynames=list(way1="way1",way2="way2",way3="way3"),
+   nodes=list(way1=C,way2=data.frame(ID=labs),way3=data.frame(ID=labs)),
+   links=data.frame(link=cbind(I,J,K)))
> write(toJSON(data),"lazegaMN.json")
> 

Reading JSON data

> MN <- fromJSON("lazegaMN.json")
> str(MN)
List of 7
 $ title   : chr "Lazega's Lawyers / 36 partners"
 $ by      : chr "E Lazega"
 $ creator : chr "V. Batagelj"
 $ date    : chr "Mon Nov  7 01:32:09 2022"
 $ waynames:List of 3
  ..$ way1: chr "way1"
  ..$ way2: chr "way2"
  ..$ way3: chr "way3"
 $ nodes   :List of 3
  ..$ way1:'data.frame':        36 obs. of  8 variables:
  .. ..$ ID        : chr [1:36] "L1" "L2" "L3" "L4" ...
  .. ..$ seniority : int [1:36] 1 2 3 4 5 6 7 8 9 10 ...
  .. ..$ gender    : chr [1:36] "man" "man" "man" "man" ...
  .. ..$ office    : chr [1:36] "Boston" "Boston" "Hartford" "Boston" ...
  .. ..$ years     : int [1:36] 31 32 13 31 31 29 29 28 25 25 ...
  .. ..$ age       : int [1:36] 64 62 67 59 59 55 63 53 53 53 ...
  .. ..$ speciality: chr [1:36] "litigation" "corporate" "litigation" "corporate" ...
  .. ..$ school    : chr [1:36] "harvard_yale" "harvard_yale" "harvard_yale" "other" ...
  ..$ way2:'data.frame':        36 obs. of  1 variable:
  .. ..$ ID: chr [1:36] "L1" "L2" "L3" "L4" ...
  ..$ way3:'data.frame':        36 obs. of  1 variable:
  .. ..$ ID: chr [1:36] "L1" "L2" "L3" "L4" ...
 $ links   :'data.frame':       3045 obs. of  3 variables:
  ..$ link.I: int [1:3045] 1 1 1 1 2 2 2 2 2 2 ...
  ..$ link.J: int [1:3045] 2 2 4 4 1 1 3 3 4 4 ...
  ..$ link.K: int [1:3045] 1 4 1 2 4 20 1 14 1 9 ...
> 

Update to current MWnets format

> MN <- fromJSON("./lazega/lazegaMN.json")
> str(MN)
> info <- list(network="Lazega36",
+   title=MN$title,by=MN$by,
+   ref="Emmanuel Lazega (2001) The Collegial Phenomenon. Oxford UP.",
+   href="https://www.stats.ox.ac.uk/~snijders/siena/Lazega_lawyers_data.htm", 
+   creator="V. Batagelj",date=date())
> str(info)
> L <- MN$links
> MT <- list(format="MWnets",info=info,ways=MN$waynames,nodes=MN$nodes,
+   links=data.frame(way1=L$link.I,way2=L$link.J,way3=L$link.K,
+   w=rep(1,length(L$link.I))),data=list())
> write(toJSON(MT),"./lazega/lazega36.json")
> str(MT)
List of 6
 $ format: chr "MWnets"
 $ info  :List of 7
  ..$ network: chr "Lazega36"
  ..$ title  : chr "Lazega's Lawyers / 36 partners"
  ..$ by     : chr "E Lazega"
  ..$ ref    : chr "Emmanuel Lazega (2001) The Collegial Phenomenon. Oxford UP."
  ..$ href   : chr "https://www.stats.ox.ac.uk/~snijders/siena/Lazega_lawyers_data.htm"
  ..$ creator: chr "V. Batagelj"
  ..$ date   : chr "Sat Nov 26 23:16:52 2022"
 $ ways  :List of 3
  ..$ way1: chr "way1"
  ..$ way2: chr "way2"
  ..$ way3: chr "way3"
 $ nodes :List of 3
  ..$ way1:'data.frame':        36 obs. of  8 variables:
  .. ..$ ID        : chr [1:36] "L1" "L2" "L3" "L4" ...
  .. ..$ seniority : int [1:36] 1 2 3 4 5 6 7 8 9 10 ...
  .. ..$ gender    : chr [1:36] "man" "man" "man" "man" ...
  .. ..$ office    : chr [1:36] "Boston" "Boston" "Hartford" "Boston" ...
  .. ..$ years     : int [1:36] 31 32 13 31 31 29 29 28 25 25 ...
  .. ..$ age       : int [1:36] 64 62 67 59 59 55 63 53 53 53 ...
  .. ..$ speciality: chr [1:36] "litigation" "corporate" "litigation" "corporate" ...
  .. ..$ school    : chr [1:36] "harvard_yale" "harvard_yale" "harvard_yale" "other" ...
  ..$ way2:'data.frame':        36 obs. of  1 variable:
  .. ..$ ID: chr [1:36] "L1" "L2" "L3" "L4" ...
  ..$ way3:'data.frame':        36 obs. of  1 variable:
  .. ..$ ID: chr [1:36] "L1" "L2" "L3" "L4" ...
 $ links :'data.frame': 3045 obs. of  4 variables:
  ..$ way1: int [1:3045] 1 1 1 1 2 2 2 2 2 2 ...
  ..$ way2: int [1:3045] 2 2 4 4 1 1 3 3 4 4 ...
  ..$ way3: int [1:3045] 1 4 1 2 4 20 1 14 1 9 ...
  ..$ w   : num [1:3045] 1 1 1 1 1 1 1 1 1 1 ...
 $ data  : list()



vlado/work/2m/mwn/lazega.txt · Last modified: 2022/11/26 23:30 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki