diff --git a/DESCRIPTION b/DESCRIPTION index 6e9f161..9752162 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dogesr Type: Package Title: Work with the Doges/Dogaresse Dataset -Version: 0.3.0 +Version: 0.4.0 Author: Juan Julián Merelo-Guervós Maintainer: Juan Julián Merelo-Guervós Description: Work with data on Venetian doges and dogaresse and the noble families of the Republic of Venice, and use it for social network analysis, as used in Merelo (2022) . @@ -16,6 +16,6 @@ VignetteBuilder: knitr RdMacros: Rdpack RoxygenNote: 7.2.1 NeedsCompilation: no -Packaged: 2023-05-28 10:35:59 UTC; jmerelo +Packaged: 2023-06-15 10:09:39 UTC; jmerelo Repository: CRAN -Date/Publication: 2023-05-28 10:50:02 UTC +Date/Publication: 2023-06-15 10:50:02 UTC diff --git a/MD5 b/MD5 index 57bc5b8..4ee1665 100644 --- a/MD5 +++ b/MD5 @@ -1,42 +1,49 @@ -6e04fbea60d96929662d726108dd4e21 *DESCRIPTION -c983aa75df1f15c8a7a830fe096c224e *NAMESPACE -d92efb0a4090c7c81fb6898590f9b5ed *NEWS.md +72bf3da7a72ebe1a398e152a10d1d524 *DESCRIPTION +2fffc5ac6f14c8ca4bf72103687c10aa *NAMESPACE +72108faa8562fc119253eafab534c816 *NEWS.md 5ca494860f345762e5ca20ebc046b926 *R/doges.R -f36ed16094b6087ce0479669daab0694 *R/doges.years.R caa74c35eb1f53d4fd4fd235b8b02b30 *R/families.R -3a1c03bd199b898a984b8de910f92452 *R/marriage.graph.R -ef265897a607ae18c2547f4981f28a6c *README.md -29fe6fd08c57f358097aecf63ff18023 *build/partial.rdb -6d2a9c08ed7c19c3e1dc7d393c2c04d9 *build/vignette.rds -7e95790fa128a88770ca99dac476046f *data/doge.families.rda -0dfdd32a261427efce1497ff43c50bf8 *data/doges.marriages.rda -883614ca55eff4644a3e40dbe24cdef4 *data/doges.rda +77e2a2bc9b38abac7cf1a887602c5fd7 *R/marriage.graph.R +c6823e379f6432d8f780a12900289f37 *R/marriage.graph.slice.R +a80a70a5c9afe7eda37a9854b2ca7222 *README.md +7e18666c56215cafc2c394f982144f6b *build/partial.rdb +9452068e2fbfee1956973fd32e7d87e6 *build/vignette.rds +660f8bab876041f72ee00ff1f51d3159 *data/doge.families.rda +9ccc2d940145adf28aedcc878acea3fd *data/doges.marriages.rda +e9f50d517a7eb633aee5d65836485067 *data/doges.rda +3b76e2fd1fd95bf79e2a4ae96a7e6fc0 *data/doges.years.rda 6c21d60801f2ba759fc31d6489113df3 *data/families.rda 10aa16960c1b73d31f5227da9730ba02 *inst/REFERENCES.bib 6a25bdc08e78429c8909e1de9cad3026 *inst/doc/counting-doge-families.R 5a2585a9407c1f9fad2a9a5f146d1dd5 *inst/doc/counting-doge-families.Rmd -36d13ff711cec3c5f417aa7453eb1660 *inst/doc/counting-doge-families.html +380169b4531a27cb1691536102f1a631 *inst/doc/counting-doge-families.html 350f5d9a9e0a5eb5a30348ae7696ae27 *inst/doc/doges-family-types.R 9f3f78c5216d6c37e9a2857b4ce799c1 *inst/doc/doges-family-types.Rmd -77fb6d71781b0e1428c78d77aa1e76c5 *inst/doc/doges-family-types.html +dba77f048d676f4adf5da41b38e6eca1 *inst/doc/doges-family-types.html 00e7cf8fdf6c27b11130a10fd93706be *inst/doc/doges-social-network.R -10fc93d4697d24d9673bdf82069d7b4f *inst/doc/doges-social-network.Rmd -4380da2f12bc7732609c4d9074db07b5 *inst/doc/doges-social-network.html -61862bef8c7d863295e3e6c0624aacd5 *inst/doc/doges-terms.R -9e70d0db982fe1ed4ee311fd75e0ea0e *inst/doc/doges-terms.Rmd -fbc534a28aac08b7b19fb24dc2818211 *inst/doc/doges-terms.html +b0ff3a52065853aedb34851db83622cb *inst/doc/doges-social-network.Rmd +ccd9bd7e514c167276a316dbf6f0b8ef *inst/doc/doges-social-network.html +a74e2f92fefe60d7bb6eefa64d82db0e *inst/doc/doges-split-social-network.R +7d5799a8b1231861a880721436629e06 *inst/doc/doges-split-social-network.Rmd +005af736e24061a814ea88c900c25315 *inst/doc/doges-split-social-network.html +161bdc49e7dbc2e07d4d16a9f850ee69 *inst/doc/doges-terms.R +701c7cd2c68b8ffba018aab49160d854 *inst/doc/doges-terms.Rmd +94e7665670680af84a9f91c2bccb15da *inst/doc/doges-terms.html 3c1b99fa60e54953f433b178b7d87f91 *inst/doges.bib 67c172b488abd266e3c350306e43fd46 *man/doge.families.Rd 0e184505f55c8dc69ddc12ca4f08c665 *man/doges.Rd 5041838acbb727af7fc3591935f9e297 *man/doges.marriages.Rd -eb1370e88a84f107ae159e449e235c6b *man/doges.years.Rd +d57174905c8ee8aef9c35372d811ea10 *man/doges.years.Rd f214f1277343c214e61f1b117a39115e *man/families.Rd cc0c8409c340c8b5efce90c8bad3d62b *man/marriage.graph.Rd +f2187d2d510a86dcb52a4db674aa8c1e *man/marriage.graph.slice.Rd 1d971f3ebe61e9a030d862e2a0eb2c63 *tests/testthat.R -9649b861ab1a5f3b92b303511e558ddf *tests/testthat/test-dogesdata.R -1c7c606abf4483566e42485c77687f41 *tests/testthat/test-dogesyearsdata.R -a858fa0b763bc9da841c99e54aba72b2 *tests/testthat/test-marriagegraph.R +67e4c0cb56799101d4a6638e7f433e3d *tests/testthat/test-dogesdata.R +d1e14f44066332f94e32fb06e4cbdcf0 *tests/testthat/test-dogesyearsdata.R +ba438b58fc6557e9584c71c25ba3ff19 *tests/testthat/test-marriagegraph-slice.R +d1d368569da96d95b9220b861996b2d5 *tests/testthat/test-marriagegraph.R 5a2585a9407c1f9fad2a9a5f146d1dd5 *vignettes/counting-doge-families.Rmd 9f3f78c5216d6c37e9a2857b4ce799c1 *vignettes/doges-family-types.Rmd -10fc93d4697d24d9673bdf82069d7b4f *vignettes/doges-social-network.Rmd -9e70d0db982fe1ed4ee311fd75e0ea0e *vignettes/doges-terms.Rmd +b0ff3a52065853aedb34851db83622cb *vignettes/doges-social-network.Rmd +7d5799a8b1231861a880721436629e06 *vignettes/doges-split-social-network.Rmd +701c7cd2c68b8ffba018aab49160d854 *vignettes/doges-terms.Rmd diff --git a/NAMESPACE b/NAMESPACE index 373fd3f..71fb470 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,4 +5,4 @@ import(qpdf) import(rmarkdown) import(ggplot2) importFrom(Rdpack,reprompt) -importFrom(igraph,graph.data.frame) +importFrom(igraph,graph.data.frame,V,"V<-") diff --git a/NEWS.md b/NEWS.md index 264ff81..1395b13 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,14 @@ +# doges 0.4.0 + +Fixes: +* Adds a missing doge to the dataset +* Fixes years in office so that they match each other + +Changes: +* Changes doges.years to dataset, not function +* Adds marriage.graph.slice +* marriage.graph now adds family type + # doges 0.3.0 Fixes: diff --git a/R/doges.years.R b/R/doges.years.R deleted file mode 100644 index 6effa54..0000000 --- a/R/doges.years.R +++ /dev/null @@ -1,19 +0,0 @@ -globalVariables(c("data.doges")) -library(dplyr) - -#' Extract just the information needed to work with the years every doge was ruling -#' -#' @return A data frame with the data for every doge, years reigning, century, family. -#' @export -#' -# - -doges.years <- function() { - data.doges.years <- data.doges - data.doges.years$Doge.raw <- NULL - data.doges.years$Dogaressa.raw <- NULL - data.doges.years$Dogaressa <- NULL - data.doges.years$Family.dogaressa <- NULL - data.doges.years$Family.mother <- NULL - return(distinct(data.doges.years)) -} diff --git a/R/marriage.graph.R b/R/marriage.graph.R index 8460dd2..f86bc3c 100644 --- a/R/marriage.graph.R +++ b/R/marriage.graph.R @@ -1,12 +1,17 @@ -globalVariables(c("doges.marriages.sn")) +library(igraph) + +globalVariables(c("doges.marriages.sn","family.types")) #' Convert doges data into a social graph #' -#' @return An graph with noble families as nodes, edges representing marriages of doges or parents +#' @importFrom igraph V V<- +#' +#' @return A graph with noble families as nodes, edges representing marriages of doges or parents; the type of family is the attribute family.type #' @export #' # marriage.graph <- function() { + V(doges.marriages.sn)$family.type <- sapply( V(doges.marriages.sn)$name, function(x) family.types[x] ) return(doges.marriages.sn) } diff --git a/R/marriage.graph.slice.R b/R/marriage.graph.slice.R new file mode 100644 index 0000000..a67294b --- /dev/null +++ b/R/marriage.graph.slice.R @@ -0,0 +1,25 @@ +library(igraph) + +globalVariables(c("data.doges")) + +#' Convert doges data into a social graph +#' @param from Exact name of the doge, Orso (first doge) by default +#' @param to Exact name of the last doge, Ludovico Manin (last one) by default +#' @return A graph with noble families as nodes, edges representing marriages of doges or parents; the type of family is the attribute family.type +#' @export +#' +# + +marriage.graph.slice <- function(..., from="Orso",to="Ludovico Manin") { + from.index <- which(data.doges$Doge == from )[1] + to.values <- which(data.doges$Doge == to ) + to.index <- to.values[length(to.values)] + sliced <- data.doges[from.index:to.index,] + doges.marriages.df <- data.frame(sliced$Family.doge,sliced$Family.dogaressa) + doges.marriages.df <- doges.marriages.df[ (doges.marriages.df$sliced.Family.doge != '' ) & (doges.marriages.df$sliced.Family.dogaressa != ''),] + doges.mothers.df <- data.frame(sliced$Family.doge,sliced$Family.mother) + doges.mothers.df <- doges.mothers.df[ (doges.mothers.df$sliced.Family.doge != '' ) & (doges.mothers.df$sliced.Family.mother != ''),] + all.links <- data.frame(doge.or.father = c(doges.marriages.df$sliced.Family.doge,doges.mothers.df$sliced.Family.doge), + dogaressa.or.mother = c(doges.marriages.df$sliced.Family.dogaressa,doges.mothers.df$sliced.Family.mother)) + return(graph.data.frame(all.links,directed=F)) +} diff --git a/README.md b/README.md index c9517c8..c4e3b77 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ # dogesR -> **Hacktoberfest**: check the [help wanted](https://github.com/JJ/dogesr/labels/help%20wanted) issues - Module (with data) to work with the dogi and dogaresse of the Venetian republic. Main intention is to analyze social networks resulting from marriages and other interactions. @@ -46,6 +44,7 @@ This package includes a couple of vignettes. Once installed, write `vignette("do * `vignette("doges-family-types")` for how to use the family types data set * `vignette("doges-terms")` to analyze the amount of time the doges lived/ruled using data provided in this package. * `vignette("doges-social-network")` to get the marriage social network of doges and parents, and make some initial exploration. +* `vignette("doges-split-social-network")` to get the marriage social network of doges and parents for slices of time, from and to specific doges; this one shows how to get the social network before and after the Serrata. * `vignette("counting-doge-families")` to work with a table of the families doges belonged to and how many times they actually "made doge" ## Work with data diff --git a/build/partial.rdb b/build/partial.rdb index 8f1eee6..4bd4fc3 100644 Binary files a/build/partial.rdb and b/build/partial.rdb differ diff --git a/build/vignette.rds b/build/vignette.rds index be79554..acfe3f1 100644 Binary files a/build/vignette.rds and b/build/vignette.rds differ diff --git a/data/doge.families.rda b/data/doge.families.rda index fa732dd..1897a5b 100644 Binary files a/data/doge.families.rda and b/data/doge.families.rda differ diff --git a/data/doges.marriages.rda b/data/doges.marriages.rda index 1bf0695..f1707f2 100644 Binary files a/data/doges.marriages.rda and b/data/doges.marriages.rda differ diff --git a/data/doges.rda b/data/doges.rda index ae66bf9..6210a50 100644 Binary files a/data/doges.rda and b/data/doges.rda differ diff --git a/data/doges.years.rda b/data/doges.years.rda new file mode 100644 index 0000000..703c54c Binary files /dev/null and b/data/doges.years.rda differ diff --git a/inst/doc/counting-doge-families.html b/inst/doc/counting-doge-families.html index f3ffe8f..1fa7f90 100644 --- a/inst/doc/counting-doge-families.html +++ b/inst/doc/counting-doge-families.html @@ -12,7 +12,7 @@ - + Using dogesr to find out about the doges families @@ -363,7 +363,7 @@

Using dogesr to find out about the doges families

JJ Merelo

-

2023-05-28

+

2023-06-15

@@ -384,9 +384,9 @@

Introduction

Set up

We load the dataset needed, called doge.families.

-
# library("dogesr") # If you have already installed this package
-devtools::load_all(".") # Comment this, uncomment above if you have installed this package
-data("doge.families")
+
# library("dogesr") # If you have already installed this package
+devtools::load_all(".") # Comment this, uncomment above if you have installed this package
+data("doge.families")

This will import the data from the dogesr package into the doge.families tibble.

@@ -394,7 +394,7 @@

Set up

Ranking families

Here’s the ranking of the families with the highest number of doges; the Contarinis and Morosinis, right on top.

-
knitr::kable(head(doge.families[order(-doge.families$n),],n=10),row.names=F,col.names=c("Doge family","Number of doges"))
+
knitr::kable(head(doge.families[order(-doge.families$n),],n=10),row.names=F,col.names=c("Doge family","Number of doges"))
@@ -447,9 +447,9 @@

Ranking families

Which types of families are these? We can use data from the rest of the packages to find out:

-
data("families")
-doge.families$type <- unname(family.types[doge.families$Family.doge])
-knitr::kable(head(doge.families[order(-doge.families$n),],n=20) %>% select(1,3),row.names=F,col.names=c("Doge family","Family type"))
+
data("families")
+doge.families$type <- unname(family.types[doge.families$Family.doge])
+knitr::kable(head(doge.families[order(-doge.families$n),],n=20) %>% select(1,3),row.names=F,col.names=c("Doge family","Family type"))
diff --git a/inst/doc/doges-family-types.html b/inst/doc/doges-family-types.html index 025afad..141f334 100644 --- a/inst/doc/doges-family-types.html +++ b/inst/doc/doges-family-types.html @@ -12,7 +12,7 @@ - +Using dogesr to work with Venetian doges family types @@ -318,20 +318,18 @@ document.body.style.height = "100%"; document.documentElement.style.width = "100%"; document.documentElement.style.height = "100%"; - if (cel) { - cel.style.position = "absolute"; - var pad = unpackPadding(sizing.padding); - cel.style.top = pad.top + "px"; - cel.style.right = pad.right + "px"; - cel.style.bottom = pad.bottom + "px"; - cel.style.left = pad.left + "px"; - el.style.width = "100%"; - el.style.height = "100%"; - } + cel.style.position = "absolute"; + var pad = unpackPadding(sizing.padding); + cel.style.top = pad.top + "px"; + cel.style.right = pad.right + "px"; + cel.style.bottom = pad.bottom + "px"; + cel.style.left = pad.left + "px"; + el.style.width = "100%"; + el.style.height = "100%"; return { - getWidth: function() { return cel.offsetWidth; }, - getHeight: function() { return cel.offsetHeight; } + getWidth: function() { return cel.getBoundingClientRect().width; }, + getHeight: function() { return cel.getBoundingClientRect().height; } }; } else { @@ -339,8 +337,8 @@ el.style.height = px(sizing.height); return { - getWidth: function() { return el.offsetWidth; }, - getHeight: function() { return el.offsetHeight; } + getWidth: function() { return cel.getBoundingClientRect().width; }, + getHeight: function() { return cel.getBoundingClientRect().height; } }; } } @@ -564,8 +562,8 @@ elementData(el, "initialized", true); if (bindingDef.initialize) { - var result = bindingDef.initialize(el, el.offsetWidth, - el.offsetHeight); + var rect = el.getBoundingClientRect(); + var result = bindingDef.initialize(el, rect.width, rect.height); elementData(el, "init_result", result); } } @@ -607,29 +605,30 @@ forEach(matches, function(el) { var sizeObj = initSizing(el, binding); + var getSize = function(el) { + if (sizeObj) { + return {w: sizeObj.getWidth(), h: sizeObj.getHeight()} + } else { + var rect = el.getBoundingClientRect(); + return {w: rect.width, h: rect.height} + } + }; + if (hasClass(el, "html-widget-static-bound")) return; el.className = el.className + " html-widget-static-bound"; var initResult; if (binding.initialize) { - initResult = binding.initialize(el, - sizeObj ? sizeObj.getWidth() : el.offsetWidth, - sizeObj ? sizeObj.getHeight() : el.offsetHeight - ); + var size = getSize(el); + initResult = binding.initialize(el, size.w, size.h); elementData(el, "init_result", initResult); } if (binding.resize) { - var lastSize = { - w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, - h: sizeObj ? sizeObj.getHeight() : el.offsetHeight - }; + var lastSize = getSize(el); var resizeHandler = function(e) { - var size = { - w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, - h: sizeObj ? sizeObj.getHeight() : el.offsetHeight - }; + var size = getSize(el); if (size.w === 0 && size.h === 0) return; if (size.w === lastSize.w && size.h === lastSize.h) @@ -931,7 +930,6 @@ return result; } })(); - +
library(tidyr)
+#> 
+#> Attaching package: 'tidyr'
+#> The following object is masked from 'package:testthat':
+#> 
+#>     matches
+#> The following object is masked from 'package:igraph':
+#> 
+#>     crossing
+library(dplyr)
+#> 
+#> Attaching package: 'dplyr'
+#> The following object is masked from 'package:testthat':
+#> 
+#>     matches
+#> The following objects are masked from 'package:igraph':
+#> 
+#>     as_data_frame, groups, union
+#> The following objects are masked from 'package:stats':
+#> 
+#>     filter, lag
+#> The following objects are masked from 'package:base':
+#> 
+#>     intersect, setdiff, setequal, union
+library(tibble)
+#> 
+#> Attaching package: 'tibble'
+#> The following object is masked from 'package:igraph':
+#> 
+#>     as_data_frame
+links <- types.adjacency  %>% as.data.frame() 
+nodes <- data.frame(
+  name=c(as.character(links$fam.type.doge), as.character(links$fam.type.dogaressa)) %>% 
+    unique()
+  )
+links$IDsource <- match(links$fam.type.doge, nodes$name)-1 
+links$IDtarget <- match(links$fam.type.dogaressa, nodes$name)-1
+
+library(networkD3)
+links <- links[ links$Freq > 0,]
+sankeyNetwork(Links = links, Nodes = nodes,
+                     Source = "IDsource", Target = "IDtarget",
+                     Value = "Freq", NodeID = "name", 
+                     sinksRight=FALSE)
+
+

The “NA” category of families seems to dominate the female part of the diagram, corresponding to dogaresse. The fact that their family name is not available is due either to non-married doges or dogaresse @@ -2972,20 +2998,20 @@

Set up

We are mostly interested, however, in the social links formed by different types of noble families, so we will simply eliminate those rows and columns to have a clearer picture.

-
types.adjacency <- types.adjacency[-1,-1]
-links2 <- types.adjacency  %>% as.data.frame() 
-nodes2 <- data.frame(
-  name=c(as.character(links2$fam.type.doge), as.character(links2$fam.type.dogaressa)) %>% 
-    unique()
-  )
-links2$IDsource <- match(links2$fam.type.doge, nodes2$name)-1 
-links2$IDtarget <- match(links2$fam.type.dogaressa, nodes2$name)-1
-links2 <- links2[ links2$Freq > 0,]
-sankeyNetwork(Links = links2, Nodes = nodes2,
-                     Source = "IDsource", Target = "IDtarget",
-                     Value = "Freq", NodeID = "name")
-
- +
types.adjacency <- types.adjacency[-1,-1]
+links2 <- types.adjacency  %>% as.data.frame() 
+nodes2 <- data.frame(
+  name=c(as.character(links2$fam.type.doge), as.character(links2$fam.type.dogaressa)) %>% 
+    unique()
+  )
+links2$IDsource <- match(links2$fam.type.doge, nodes2$name)-1 
+links2$IDtarget <- match(links2$fam.type.dogaressa, nodes2$name)-1
+links2 <- links2[ links2$Freq > 0,]
+sankeyNetwork(Links = links2, Nodes = nodes2,
+                     Source = "IDsource", Target = "IDtarget",
+                     Value = "Freq", NodeID = "name")
+
+

What we see here is the popularity of apostoliche dogaresse, and of ducali doges. But also how common marrying up was. Apostolochie families couldn’t marry up, since diff --git a/inst/doc/doges-social-network.Rmd b/inst/doc/doges-social-network.Rmd index 52260f6..86f299b 100644 --- a/inst/doc/doges-social-network.Rmd +++ b/inst/doc/doges-social-network.Rmd @@ -48,7 +48,7 @@ doges.sn.connected <- igraph::induced_subgraph(doges.sn, vert_ids) plot(doges.sn.connected,vertex.size=V(doges.sn.connected)$degree,layout=layout_with_fr, vertex.label.cex=0.7) ``` -This already shows (roughly) the power-law structure that was already evident in [@dogesr]; however, looking at Figure 1 in that paper, we see that some families that were "excluded" if doges' parents are not included in the social network, are now part of the connected component. The Lando, Pasqualigo and Querini families were then "outside", and they are now linked through some matrilinear relationship. We'll check now which are the links in this case, as well as other that were also isolated previously. +This already shows the multi-center structure, with several strong families as nuclei, that was already evident in [@dogesr]; however, looking at Figure 1 in that paper, we see that some families that were "excluded" if doges' parents are not included in the social network, are now part of the connected component. The Lando, Pasqualigo and Querini families were then "outside", and they are now linked through some matrilinear relationship. We'll check now which are the links in this case, as well as other that were also isolated previously. ```{r newlinks} for (f in c("Pasqualigo","Foscari","Querini")) { diff --git a/inst/doc/doges-social-network.html b/inst/doc/doges-social-network.html index 47a4e29..bea2986 100644 --- a/inst/doc/doges-social-network.html +++ b/inst/doc/doges-social-network.html @@ -12,7 +12,7 @@ - + Using dogesr to work with the social network of Venetian doges’ families @@ -363,7 +363,7 @@

Using dogesr to work with the social network of Venetian doges’ families

JJ Merelo

-

2023-05-28

+

2023-06-15

@@ -376,45 +376,45 @@

Introduction

Set up

-
library(dogesr)
-library(igraph)
-doges.sn <- marriage.graph()
+
library(dogesr)
+library(igraph)
+doges.sn <- marriage.graph()

This will call the function that creates, from raw data, the igraph data structure with which we can work. We still need to simplify this net to be able to work with it.

-
E(doges.sn)$weight <- 1
-doges.sn <- simplify(doges.sn, edge.attr.comb=list(weight="sum"))
-V(doges.sn)$degree <- degree(doges.sn)
-plot(doges.sn,vertex.size=V(doges.sn)$degree, layout=layout_with_kk, vertex.label.cex=0.7)
-

+
E(doges.sn)$weight <- 1
+doges.sn <- simplify(doges.sn, edge.attr.comb=list(weight="sum"))
+V(doges.sn)$degree <- degree(doges.sn)
+plot(doges.sn,vertex.size=V(doges.sn)$degree, layout=layout_with_kk, vertex.label.cex=0.7)
+

Although not very clearly in this rendering (better if you run this in your own RStudio), we can at least see that there is a big connected component, and a set of components that are disconnected. Let us try and extract that component

-
components <- igraph::clusters(doges.sn, mode="weak")
-biggest_cluster_id <- which.max(components$csize)
-vert_ids <- V(doges.sn)[components$membership == biggest_cluster_id]
-
-doges.sn.connected <- igraph::induced_subgraph(doges.sn, vert_ids)
-plot(doges.sn.connected,vertex.size=V(doges.sn.connected)$degree,layout=layout_with_fr, vertex.label.cex=0.7)
-

-

This already shows (roughly) the power-law structure that was already -evident in (Merelo-Guervós 2022); however, -looking at Figure 1 in that paper, we see that some families that were -“excluded” if doges’ parents are not included in the social network, are -now part of the connected component. The Lando, Pasqualigo and Querini -families were then “outside”, and they are now linked through some -matrilinear relationship. We’ll check now which are the links in this -case, as well as other that were also isolated previously.

-
for (f in c("Pasqualigo","Foscari","Querini")) {
-  print(incident(doges.sn,as.numeric(V(doges.sn)[f])))
-}
-#> + 2/83 edges from f2719b9 (vertex names):
-#> [1] Loredan--Pasqualigo Lando  --Pasqualigo
-#> + 3/83 edges from f2719b9 (vertex names):
-#> [1] Foscari--Priuli  Foscari--Sagredo Foscari--Nani   
-#> + 2/83 edges from f2719b9 (vertex names):
-#> [1] Gradenigo--Querini Valier   --Querini
+
components <- igraph::clusters(doges.sn, mode="weak")
+biggest_cluster_id <- which.max(components$csize)
+vert_ids <- V(doges.sn)[components$membership == biggest_cluster_id]
+
+doges.sn.connected <- igraph::induced_subgraph(doges.sn, vert_ids)
+plot(doges.sn.connected,vertex.size=V(doges.sn.connected)$degree,layout=layout_with_fr, vertex.label.cex=0.7)
+

+

This already shows the multi-center structure, with several strong +families as nuclei, that was already evident in (Merelo-Guervós 2022); however, looking at +Figure 1 in that paper, we see that some families that were “excluded” +if doges’ parents are not included in the social network, are now part +of the connected component. The Lando, Pasqualigo and Querini families +were then “outside”, and they are now linked through some matrilinear +relationship. We’ll check now which are the links in this case, as well +as other that were also isolated previously.

+
for (f in c("Pasqualigo","Foscari","Querini")) {
+  print(incident(doges.sn,as.numeric(V(doges.sn)[f])))
+}
+#> + 2/84 edges from 26e4fcf (vertex names):
+#> [1] Loredan--Pasqualigo Lando  --Pasqualigo
+#> + 3/84 edges from 26e4fcf (vertex names):
+#> [1] Foscari--Priuli  Foscari--Sagredo Foscari--Nani   
+#> + 2/84 edges from 26e4fcf (vertex names):
+#> [1] Gradenigo--Querini Valier   --Querini

Other than that, we can see that the same families are at the center of the social network: Dandolo, Morosini, Contarini, all those families that appear over and over again through the history of the Republic. diff --git a/inst/doc/doges-split-social-network.R b/inst/doc/doges-split-social-network.R new file mode 100644 index 0000000..a79b1f7 --- /dev/null +++ b/inst/doc/doges-split-social-network.R @@ -0,0 +1,28 @@ +## ----setup, include = FALSE--------------------------------------------------- +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) + +## ----load, warning=FALSE,message=FALSE---------------------------------------- +library(dogesr) +library(igraph) + +pre.serrata <- marriage.graph.slice(to="Pietro Gradenigo") +post.serrata <- marriage.graph.slice(from="Marino Zorzi") + +## ----simplify----------------------------------------------------------------- +weightify <- function( a.graph ) { + other.graph <- a.graph + E(other.graph)$weight <- 1 + other.graph <- simplify(other.graph, edge.attr.comb=list(weight="sum")) + return(other.graph) +} +pre.serrata <- weightify(pre.serrata) +post.serrata <- weightify(post.serrata) + +V(pre.serrata)$EV <- unname(unlist(eigen_centrality(pre.serrata)$vector)) +V(post.serrata)$EV <- unname(unlist(eigen_centrality(post.serrata)$vector)) +plot(pre.serrata,vertex.size=V(pre.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) +plot(post.serrata,vertex.size=V(post.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) + diff --git a/inst/doc/doges-split-social-network.Rmd b/inst/doc/doges-split-social-network.Rmd new file mode 100644 index 0000000..13c1430 --- /dev/null +++ b/inst/doc/doges-split-social-network.Rmd @@ -0,0 +1,60 @@ +--- +title: "Using `dogesr` to check Venetian social networks before and after the Serrata" +author: "JJ Merelo" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using `dogesr` to check Venetian social networks before and after the Serrata} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +bibliography: ../inst/doges.bib +--- + +```{r setup, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +## Introduction + +Using data from `dogesr` [@dogesr], we will, in this vignette, analyze the change of the social network before and after the *Serrata* [@serrata], revealed as a watershed event in the analysis performed in [@histories:jj] + +## Set up + +The Serrata mainly happened during the government of Pietro Gradenigo. We will then create two networks, one including that doge, the next one with all the others +```{r load, warning=FALSE,message=FALSE} +library(dogesr) +library(igraph) + +pre.serrata <- marriage.graph.slice(to="Pietro Gradenigo") +post.serrata <- marriage.graph.slice(from="Marino Zorzi") +``` + +This will call the function that creates, from raw data, the `igraph` data structure with which we can work. We still need to simplify them to be able to work with it. +```{r simplify} +weightify <- function( a.graph ) { + other.graph <- a.graph + E(other.graph)$weight <- 1 + other.graph <- simplify(other.graph, edge.attr.comb=list(weight="sum")) + return(other.graph) +} +pre.serrata <- weightify(pre.serrata) +post.serrata <- weightify(post.serrata) + +V(pre.serrata)$EV <- unname(unlist(eigen_centrality(pre.serrata)$vector)) +V(post.serrata)$EV <- unname(unlist(eigen_centrality(post.serrata)$vector)) +plot(pre.serrata,vertex.size=V(pre.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) +plot(post.serrata,vertex.size=V(post.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) +``` + +The pre-Serrata graph is above, the post-serrata below. Before the Serrata, there were small (up to 4-5) sets of connected components, the biggest one the "star" around the Tiepolo family (which was an important part of the early XIV century rebellion); however, the Serrata had the effect of connecting the network, mainly because there were far many doges (as explained in [@histories:jj]), but also because marrying became an tactical move to increase the reach of the social network. + +It should be noted, however, that doges' marriages were but a small part of the complete social network; however, it is an important sample that, besides, shows who arrived to the summit of power (or servitude to the state, depending on how you look at it) + +## Conclusions + +Charting the doges social networks enables insights on the power and social dynamics of the Republic of Venice; being able to look at temporal slices is especially interesting since we can check how certain events influenced the social network. + +## References diff --git a/inst/doc/doges-split-social-network.html b/inst/doc/doges-split-social-network.html new file mode 100644 index 0000000..5e15e53 --- /dev/null +++ b/inst/doc/doges-split-social-network.html @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + +Using dogesr to check Venetian social networks before and after the Serrata + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Using dogesr to check Venetian +social networks before and after the Serrata

+

JJ Merelo

+

2023-06-15

+ + + +
+

Introduction

+

Using data from dogesr (Merelo-Guervós 2022), we will, in this +vignette, analyze the change of the social network before and after the +Serrata (Puga and Trefler 2014), +revealed as a watershed event in the analysis performed in (Merelo 2023)

+
+
+

Set up

+

The Serrata mainly happened during the government of Pietro +Gradenigo. We will then create two networks, one including that doge, +the next one with all the others

+
library(dogesr)
+library(igraph)
+
+pre.serrata <- marriage.graph.slice(to="Pietro Gradenigo")
+post.serrata <- marriage.graph.slice(from="Marino Zorzi")
+

This will call the function that creates, from raw data, the +igraph data structure with which we can work. We still need +to simplify them to be able to work with it.

+
weightify <- function( a.graph ) {
+  other.graph <- a.graph
+  E(other.graph)$weight <- 1
+  other.graph <- simplify(other.graph, edge.attr.comb=list(weight="sum"))
+  return(other.graph)
+}
+pre.serrata <- weightify(pre.serrata)
+post.serrata <- weightify(post.serrata)
+
+V(pre.serrata)$EV <- unname(unlist(eigen_centrality(pre.serrata)$vector))
+V(post.serrata)$EV <- unname(unlist(eigen_centrality(post.serrata)$vector))
+plot(pre.serrata,vertex.size=V(pre.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7)
+

+
plot(post.serrata,vertex.size=V(post.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7)
+

+

The pre-Serrata graph is above, the post-serrata below. Before the +Serrata, there were small (up to 4-5) sets of connected components, the +biggest one the “star” around the Tiepolo family (which was an important +part of the early XIV century rebellion); however, the Serrata had the +effect of connecting the network, mainly because there were far many +doges (as explained in (Merelo 2023)), but +also because marrying became an tactical move to increase the reach of +the social network.

+

It should be noted, however, that doges’ marriages were but a small +part of the complete social network; however, it is an important sample +that, besides, shows who arrived to the summit of power (or servitude to +the state, depending on how you look at it)

+
+
+

Conclusions

+

Charting the doges social networks enables insights on the power and +social dynamics of the Republic of Venice; being able to look at +temporal slices is especially interesting since we can check how certain +events influenced the social network.

+
+
+

References

+
+
+Merelo, Juan J. 2023. “It’s a Doge’s Life: Examining Term Limits +in Venetian Doges’ Life Tenure.” Histories +3 (1): 21–31. https://doi.org/10.3390/histories3010003. +
+
+Merelo-Guervós, J. J. 2022. “What Is a Good Doge? +Analyzing the Patrician Social Network of the Republic of Venice.” arXiv. https://doi.org/10.48550/ARXIV.2209.07334. +
+
+Puga, Diego, and Daniel Trefler. 2014. International Trade and Institutional Change: Medieval +Venice’s Response to Globalization.” The Quarterly +Journal of Economics 129 (2): 753–821. https://doi.org/10.1093/qje/qju006. +
+
+
+ + + + + + + + + + + diff --git a/inst/doc/doges-terms.R b/inst/doc/doges-terms.R index ce74a57..7420ee5 100644 --- a/inst/doc/doges-terms.R +++ b/inst/doc/doges-terms.R @@ -22,27 +22,27 @@ knitr::kable(doges.one.year[order(doges.one.year$years),],col.names=NULL) knitr::kable(doges.all.years[which.max(doges.all.years$years),]) ## ----using.doges.years-------------------------------------------------------- -doges.years.all <- doges.years() -knitr::kable(head(doges.years.all[order(-doges.years.all$Years),],10)) +data("doges.years") +knitr::kable(head(doges.years[order(-doges.years$Years),],10)) ## ----distribution, fig.cap="This histogram reproduces, with a fixed bin size, Figure 1 in [@smith2021long]."---- library(ggplot2) -ggplot(doges.years.all, aes(x=Years))+geom_histogram(binwidth=5) +ggplot(doges.years, aes(x=Years))+geom_histogram(binwidth=5) ## ----boxplot------------------------------------------------------------------ -doges.years.all$Century <- as.factor(doges.years.all$Century) -ggplot(doges.years.all, aes(x=Century,y=Years))+geom_boxplot() +doges.years$Century <- as.factor(doges.years$Century) +ggplot(doges.years, aes(x=Century,y=Years))+geom_boxplot() ## ----serrata------------------------------------------------------------------ -doges.years.all$pre.serrata <- TRUE -doges.years.all[doges.years.all$Start >= 1297,]$pre.serrata <- FALSE -means <- aggregate(Years ~ pre.serrata, doges.years.all, mean) -medians <- aggregate(Years ~ pre.serrata, doges.years.all, median) -ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ +doges.years$pre.serrata <- TRUE +doges.years[doges.years$Start >= 1297,]$pre.serrata <- FALSE +means <- aggregate(Years ~ pre.serrata, doges.years, mean) +medians <- aggregate(Years ~ pre.serrata, doges.years, median) +ggplot(doges.years, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ stat_summary(fun=mean, geom="point", shape=20, size=3, color="red", fill="red") + geom_text(data = means, aes(label = round(Years, 2), y = Years + 2), size = 3) + geom_text(data = medians, aes(label = round(Years, 2), y = Years - 1), size = 3) ## ----wilcox------------------------------------------------------------------- -wilcox.test(doges.years.all[doges.years.all$pre.serrata == T,]$Years, doges.years.all[doges.years.all$pre.serrata == F,]$Years ) +wilcox.test(doges.years[doges.years$pre.serrata == T,]$Years, doges.years[doges.years$pre.serrata == F,]$Years ) diff --git a/inst/doc/doges-terms.Rmd b/inst/doc/doges-terms.Rmd index 72a2ef3..79339b3 100644 --- a/inst/doc/doges-terms.Rmd +++ b/inst/doc/doges-terms.Rmd @@ -62,8 +62,8 @@ We can see whether this has any kind of influence using now several functions pr This can be analyzed a but further with a function provided by `dogesr`, `doges.years`. This filters part of the original data, leaving only data needed to work with the doges' terms (or years) ```{r using.doges.years} -doges.years.all <- doges.years() -knitr::kable(head(doges.years.all[order(-doges.years.all$Years),],10)) +data("doges.years") +knitr::kable(head(doges.years[order(-doges.years$Years),],10)) ``` First thing we can note is that, among the top 10, there is only one, Leonardo Loredan, who was elected after the aforementioned Francesco Foscari. This was, according to everyone, an unexpected event [@loredan], and he was chosen by the minimum needed to get elected. So he was really an outlier. The distribution in bins of 5 years, below, shows how infrequent was a term of more than 10 years. @@ -72,24 +72,24 @@ First thing we can note is that, among the top 10, there is only one, Leonardo L ```{r distribution, fig.cap="This histogram reproduces, with a fixed bin size, Figure 1 in [@smith2021long]."} library(ggplot2) -ggplot(doges.years.all, aes(x=Years))+geom_histogram(binwidth=5) +ggplot(doges.years, aes(x=Years))+geom_histogram(binwidth=5) ``` The distribution is skewed because it includes the first years of the institution. This is the distribution by centuries ```{r boxplot} -doges.years.all$Century <- as.factor(doges.years.all$Century) -ggplot(doges.years.all, aes(x=Century,y=Years))+geom_boxplot() +doges.years$Century <- as.factor(doges.years$Century) +ggplot(doges.years, aes(x=Century,y=Years))+geom_boxplot() ``` There seems to be a clear difference before and after the thirteenth century; there is also a return to longer tenures by the end of the Republic, in the 18th century. Was there a real difference? ```{r serrata} -doges.years.all$pre.serrata <- TRUE -doges.years.all[doges.years.all$Start >= 1297,]$pre.serrata <- FALSE -means <- aggregate(Years ~ pre.serrata, doges.years.all, mean) -medians <- aggregate(Years ~ pre.serrata, doges.years.all, median) -ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ +doges.years$pre.serrata <- TRUE +doges.years[doges.years$Start >= 1297,]$pre.serrata <- FALSE +means <- aggregate(Years ~ pre.serrata, doges.years, mean) +medians <- aggregate(Years ~ pre.serrata, doges.years, median) +ggplot(doges.years, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ stat_summary(fun=mean, geom="point", shape=20, size=3, color="red", fill="red") + geom_text(data = means, aes(label = round(Years, 2), y = Years + 2), size = 3) + geom_text(data = medians, aes(label = round(Years, 2), y = Years - 1), size = 3) @@ -98,12 +98,12 @@ ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ This difference is significant, as indicated by the Wilcoxon test ```{r wilcox} -wilcox.test(doges.years.all[doges.years.all$pre.serrata == T,]$Years, doges.years.all[doges.years.all$pre.serrata == F,]$Years ) +wilcox.test(doges.years[doges.years$pre.serrata == T,]$Years, doges.years[doges.years$pre.serrata == F,]$Years ) ``` ## Conclusions -As indicated by [@smith2021long], there seems to be evidence in the term limits of doges of the Republic of Venice. In their paper they indicate 1172 as a departure point for the term "limits", when the Maggior Consiglio was formed. According to the figure above, there does not seem to be a significant difference between the XII and XIII century in terms of tenure. However, 1297 does seem to be a watershed event, with all terms after that being significantly different to terms prior to it. We can conclude, then, that the Serrata, closing of the Maggior Consiglio to all but a few patrician families, was in fact the event that marked the shift to electing older doges. +As indicated by [@smith2021long], there seems to be evidence that supports the existence of "informal" limits on the terms of doges of the the Republic of Venice. In their paper they indicate 1172 as a departure point for the term "limits", when the Maggior Consiglio was formed. According to the figure above, there does not seem to be a significant difference between the XII and XIII century in terms of tenure. However, 1297 does seem to be a watershed event, with all terms after that being significantly different to terms prior to it. We can conclude, then, that the Serrata, closing of the Maggior Consiglio to all but a few patrician families, was in fact the event that marked the shift to electing older doges. This vignette also shows how, using `dogesr`, it becomes significantly easier for everyone with the skill to work with the R language to reproduce or work upon results related to life terms and other Venetian doges data. diff --git a/inst/doc/doges-terms.html b/inst/doc/doges-terms.html index be5623f..1a5fea0 100644 --- a/inst/doc/doges-terms.html +++ b/inst/doc/doges-terms.html @@ -12,7 +12,7 @@ - + Using dogesr to work with Venetian doges tenures @@ -363,7 +363,7 @@

Using dogesr to work with Venetian doges tenures

JJ Merelo

-

2023-05-28

+

2023-06-15

@@ -379,36 +379,18 @@

Introduction

Set up

-
library(dogesr)
-data("doges")
+
library(dogesr)
+data("doges")

This will import the data from the dogesr package into the data.doges data frame. We are interested in the Doges and Years variables. Let’s create a data frame out of that:

-
doges.all.years <- data.frame( doge = data.doges$Doge, years = data.doges$Years)
+
doges.all.years <- data.frame( doge = data.doges$Doge, years = data.doges$Years)

Several doges only were able to stay alive during the same year

-
knitr::kable(doges.all.years[doges.all.years$years == 0,]$doge, col.names=NULL)
+
knitr::kable(doges.all.years[doges.all.years$years == 0,]$doge, col.names=NULL)
- - - - - - - - - - - - - - - - - - @@ -420,122 +402,122 @@

Set up

Domenico Leone
Felice Cornicula
Teodato
Gioviano
Giovanni Fabriciaco
Pietro I Candiano
Michele Morosini

And quite a few during one year or less

-
doges.one.year <- unique(doges.all.years[doges.all.years$years <= 1,])
-knitr::kable(doges.one.year[order(doges.one.year$years),],col.names=NULL)
+
doges.one.year <- unique(doges.all.years[doges.all.years$years <= 1,])
+knitr::kable(doges.one.year[order(doges.one.year$years),],col.names=NULL)
- - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -544,7 +526,7 @@

Set up

So it effectively looks like most doges effectively had a short shelf life. As a matter of fact, the doge that staid in power the longest was

-
knitr::kable(doges.all.years[which.max(doges.all.years$years),])
+
knitr::kable(doges.all.years[which.max(doges.all.years$years),])
2Domenico Leone71Michele Morosini 0
3Felice Cornicula107Nicolo Donato 0
4Teodato115Francesco Corner 0
5Gioviano02Domenico Leone1
6Giovanni Fabriciaco03Felice Cornicula1
19Pietro I Candiano04Teodato1
70Michele Morosini05Gioviano1
106Nicolo Donato06Giovanni Fabriciaco1
114Francesco Corner0
8 Galla Gaulo 1
19Pietro I Candiano1
28 Vitale Candiano 1
5758 Marino Zorzi 1
6263 Marino Faliero 1
6465 Giovanni Gradenigo 1
7980 Nicolo Marcello 1
8485 Marco Barbarigo 1
9293 Marcantonio Trivisan 1
99100 Sebastiano Venier 1
108109 Francesco Contarini 1
110111 Nicolo Contarini 1
113114 Carlo Contarini 1
116117 Giovanni Pesaro 1
130131 Marco Foscarini 1
@@ -555,7 +537,7 @@

Set up

- + @@ -575,8 +557,8 @@

Analyzing the evolution of the effective terms of the doges using dogesr, doges.years. This filters part of the original data, leaving only data needed to work with the doges’ terms (or years)

-
doges.years.all <- doges.years()
-knitr::kable(head(doges.years.all[order(-doges.years.all$Years),],10))
+
data("doges.years")
+knitr::kable(head(doges.years[order(-doges.years$Years),],10))

7475 Francesco Foscari 34
@@ -591,7 +573,7 @@

Analyzing the evolution of the effective terms of the doges using

- + @@ -627,7 +609,7 @@

Analyzing the evolution of the effective terms of the doges using

- + @@ -645,7 +627,7 @@

Analyzing the evolution of the effective terms of the doges using

- + @@ -663,7 +645,7 @@

Analyzing the evolution of the effective terms of the doges using

- + @@ -672,7 +654,7 @@

Analyzing the evolution of the effective terms of the doges using

- + @@ -692,53 +674,54 @@

Analyzing the evolution of the effective terms of the doges using

In fact, doges’ years of ruling were as short as the life of the common dog.

-
library(ggplot2)
-ggplot(doges.years.all, aes(x=Years))+geom_histogram(binwidth=5)
-
- -

This histogram reproduces, with a fixed bin size, -Figure 1 in (Smith, Crowley, and Leguizamon -2021).

+
library(ggplot2)
+ggplot(doges.years, aes(x=Years))+geom_histogram(binwidth=5)
+
+This histogram reproduces, with a fixed bin size, Figure 1 in (Smith, Crowley, and Leguizamon 2021). +
This histogram reproduces, with a fixed bin +size, Figure 1 in (Smith, Crowley, and Leguizamon +2021).

The distribution is skewed because it includes the first years of the institution. This is the distribution by centuries

-
doges.years.all$Century <- as.factor(doges.years.all$Century)
-ggplot(doges.years.all, aes(x=Century,y=Years))+geom_boxplot()
-

+
doges.years$Century <- as.factor(doges.years$Century)
+ggplot(doges.years, aes(x=Century,y=Years))+geom_boxplot()
+

There seems to be a clear difference before and after the thirteenth century; there is also a return to longer tenures by the end of the Republic, in the 18th century. Was there a real difference?

-
doges.years.all$pre.serrata <- TRUE
-doges.years.all[doges.years.all$Start >= 1297,]$pre.serrata <- FALSE
-means <- aggregate(Years ~  pre.serrata, doges.years.all, mean)
-medians <- aggregate(Years ~  pre.serrata, doges.years.all, median)
-ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+
-  stat_summary(fun=mean, geom="point", shape=20, size=3, color="red", fill="red") +
-  geom_text(data = means, aes(label = round(Years, 2), y = Years + 2), size = 3) + 
-  geom_text(data = medians, aes(label = round(Years, 2), y = Years - 1), size = 3)
-

+
doges.years$pre.serrata <- TRUE
+doges.years[doges.years$Start >= 1297,]$pre.serrata <- FALSE
+means <- aggregate(Years ~  pre.serrata, doges.years, mean)
+medians <- aggregate(Years ~  pre.serrata, doges.years, median)
+ggplot(doges.years, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+
+  stat_summary(fun=mean, geom="point", shape=20, size=3, color="red", fill="red") +
+  geom_text(data = means, aes(label = round(Years, 2), y = Years + 2), size = 3) + 
+  geom_text(data = medians, aes(label = round(Years, 2), y = Years - 1), size = 3)
+

This difference is significant, as indicated by the Wilcoxon test

-
wilcox.test(doges.years.all[doges.years.all$pre.serrata == T,]$Years,   doges.years.all[doges.years.all$pre.serrata == F,]$Years )
-#> 
-#>  Wilcoxon rank sum test with continuity correction
-#> 
-#> data:  doges.years.all[doges.years.all$pre.serrata == T, ]$Years and doges.years.all[doges.years.all$pre.serrata == F, ]$Years
-#> W = 2350, p-value = 0.005055
-#> alternative hypothesis: true location shift is not equal to 0
+
wilcox.test(doges.years[doges.years$pre.serrata == T,]$Years,   doges.years[doges.years$pre.serrata == F,]$Years )
+#> 
+#>  Wilcoxon rank sum test with continuity correction
+#> 
+#> data:  doges.years[doges.years$pre.serrata == T, ]$Years and doges.years[doges.years$pre.serrata == F, ]$Years
+#> W = 2467.5, p-value = 0.001425
+#> alternative hypothesis: true location shift is not equal to 0

Conclusions

As indicated by (Smith, Crowley, and -Leguizamon 2021), there seems to be evidence in the term limits -of doges of the Republic of Venice. In their paper they indicate 1172 as -a departure point for the term “limits”, when the Maggior Consiglio was -formed. According to the figure above, there does not seem to be a -significant difference between the XII and XIII century in terms of -tenure. However, 1297 does seem to be a watershed event, with all terms -after that being significantly different to terms prior to it. We can -conclude, then, that the Serrata, closing of the Maggior Consiglio to -all but a few patrician families, was in fact the event that marked the -shift to electing older doges.

+Leguizamon 2021), there seems to be evidence that supports the +existence of “informal” limits on the terms of doges of the the Republic +of Venice. In their paper they indicate 1172 as a departure point for +the term “limits”, when the Maggior Consiglio was formed. According to +the figure above, there does not seem to be a significant difference +between the XII and XIII century in terms of tenure. However, 1297 does +seem to be a watershed event, with all terms after that being +significantly different to terms prior to it. We can conclude, then, +that the Serrata, closing of the Maggior Consiglio to all but a few +patrician families, was in fact the event that marked the shift to +electing older doges.

This vignette also shows how, using dogesr, it becomes significantly easier for everyone with the skill to work with the R language to reproduce or work upon results related to life terms and diff --git a/man/doges.years.Rd b/man/doges.years.Rd index a129114..6a23f7b 100644 --- a/man/doges.years.Rd +++ b/man/doges.years.Rd @@ -2,16 +2,16 @@ \alias{doges.years} %- Also NEED an '\alias' for EACH other topic documented here. \title{ -Sub-dataset with years they were ruling. +Sub-dataset with the list of doges, their family and when it happened. } \description{ -Create a sub-dataset with doge data and reigning years. +A dataset with doge data and the years their reign started and ended. } \usage{ -doges.years() +data("doges.years") } \details{ -Eliminates data from the original dataset \code{doges} \insertRef{dogesr}{dogesr} referring to dogaresse, and leaves just data for the doges, eliminating also the "raw" column. +It's essentially the original dataset \code{doges} \insertRef{dogesr}{dogesr}, minus data referring to dogaresse, and leaves just data for the doges, eliminating also the "raw" columns. } \value{ A dataframe with the columns \code{Doge, Century, Start, End, Family, Years} @@ -24,15 +24,13 @@ A dataframe with the columns \code{Doge, Century, Start, End, Family, Years} Data originally from the Wikipedia } -%% ~Make other sections like Warning with \section{Warning }{....} ~ - \seealso{ \code{link{doges}} } \examples{ library(dogesr) -data.doges.years <- doges.years() -summary(data.doges.years$Years) +data("doges.years") +summary(doges.years$Years) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory (show via RShowDoc("KEYWORDS")): diff --git a/man/marriage.graph.slice.Rd b/man/marriage.graph.slice.Rd new file mode 100644 index 0000000..2306349 --- /dev/null +++ b/man/marriage.graph.slice.Rd @@ -0,0 +1,61 @@ +\name{marriage.graph.slice} +\alias{marriage.graph.slice} +\title{Data on doges' matrimonial links} + +\description{ +Partial graph of doge marriages as an \code{igraph} object; it includes doges' marriages, as well as their fathers', when available, but only for the period comprised between the two doges indicated +} + +\usage{ +marriage.graph.slice(...,from="Orso",to="Ludovico Manin") +} + +\arguments{ +\item{...}{Not really used} +\item{from}{A doge name, the first by default} + +\item{to}{Another doge name, the last by default} +} +\details{ +The result of calling the function is an \code{igraph} object, which you can use to plot the doges social network. Nodes are families, or "casate", and links indicate a wedding has taken place between the two families. The doges not comprised between the two slices, or the beginning or end and the indicated last or first, are not included. +} + +\value{ +A list that can be used as an \code{igraph} object, with noble family names as vertices and edges indicating links +} + +\references{ +\insertAllCited{} +} +\author{J. J. Merelo} +\note{ +Data originally from the Wikipedia +} + +\seealso{ +\code{link{doges}} +\code{link{marriage.graph}} +} + +\examples{ +library(dogesr) +library(igraph) + +# From that one to the end +from.sagredo <- marriage.graph.slice( from="Nicolo Sagredo") + +# From the first one to Sagredo +to.sagredo <- marriage.graph.slice( to="Nicolo Sagredo") + +# From the first to the last Contarini +from.sagredo <- marriage.graph.slice( + from="Domenico I Contarini", + to="Luigi Contarini" + ) + +} + +\keyword{ Venice } +\keyword{ Republica Serenissima } +\keyword{ Digital Humanities} +\keyword{ Social Network Analysis } diff --git a/tests/testthat/test-dogesdata.R b/tests/testthat/test-dogesdata.R index d1dc999..32281d5 100644 --- a/tests/testthat/test-dogesdata.R +++ b/tests/testthat/test-dogesdata.R @@ -2,6 +2,11 @@ data("doges") test_that("data is loaded", { expect_vector(data.doges) expect_length(data.doges,11) - expect_equal(nrow(data.doges),135) + expect_equal(nrow(data.doges),136) +}) + +test_that("doges have family names", { + for ( doge in 1:nrow(data.doges)){ + expect_true(data.doges[doge,]$Family.doge != '') + } }) -data diff --git a/tests/testthat/test-dogesyearsdata.R b/tests/testthat/test-dogesyearsdata.R index 34c4cdb..ab6b093 100644 --- a/tests/testthat/test-dogesyearsdata.R +++ b/tests/testthat/test-dogesyearsdata.R @@ -1,7 +1,12 @@ -data.doges.years <- doges.years() +data("doges.years") test_that("data doges years is loaded", { - expect_vector(data.doges.years) - expect_length(data.doges.years,6) - expect_equal(nrow(data.doges.years),122) + expect_vector(doges.years) + expect_length(doges.years,6) + expect_equal(nrow(doges.years),123) }) +test_that("There are no gaps in doges", { + for ( doge in 1:90){ + expect_equal(doges.years[doge,]$End, doges.years[doge+1,]$Start) + } +}) diff --git a/tests/testthat/test-marriagegraph-slice.R b/tests/testthat/test-marriagegraph-slice.R new file mode 100644 index 0000000..6eb740e --- /dev/null +++ b/tests/testthat/test-marriagegraph-slice.R @@ -0,0 +1,32 @@ +library(igraph) + +orso <- "Orso" +manin <- "Ludovico Manin" + +test_that("'to' slices work", { + to.doge <- "Pietro IV Candiano" + this.marriage.graph <- marriage.graph.slice(to=to.doge) + expect_type(this.marriage.graph,"list") + expect_equal(V(this.marriage.graph)["Pietro"]$name,"Pietro") + expect_equal(V(this.marriage.graph)["Candiano"]$name,"Candiano") +}) + + +test_that("'from' slices work", { + from.doge <- "Pietro IV Candiano" + this.marriage.graph <- marriage.graph.slice(from=from.doge) + expect_type(this.marriage.graph,"list") + expect_equal(V(this.marriage.graph)["Manin"]$name,"Manin") + expect_equal(V(this.marriage.graph)["Candiano"]$name,"Candiano") +}) + +test_that("full slices work", { + from.doge <- "Pietro IV Candiano" + to.doge <- "Francesco Erizzo" + this.marriage.graph <- marriage.graph.slice(from=from.doge,to=to.doge) + expect_type(this.marriage.graph,"list") + expect_equal(V(this.marriage.graph)["Candiano"]$name,"Candiano") + expect_equal(V(this.marriage.graph)["Orseolo"]$name,"Orseolo") +}) + + diff --git a/tests/testthat/test-marriagegraph.R b/tests/testthat/test-marriagegraph.R index ee45699..151d126 100644 --- a/tests/testthat/test-marriagegraph.R +++ b/tests/testthat/test-marriagegraph.R @@ -8,4 +8,6 @@ test_that("we have specific edges", { expect_true(are_adjacent(this.marriage.graph, "Candiano","Candiano")) }) - +test_that("family types are assigned", { + expect_equal(V(this.marriage.graph)["Basadonna"]$family.type,"Nuove") +}) diff --git a/vignettes/doges-social-network.Rmd b/vignettes/doges-social-network.Rmd index 52260f6..86f299b 100644 --- a/vignettes/doges-social-network.Rmd +++ b/vignettes/doges-social-network.Rmd @@ -48,7 +48,7 @@ doges.sn.connected <- igraph::induced_subgraph(doges.sn, vert_ids) plot(doges.sn.connected,vertex.size=V(doges.sn.connected)$degree,layout=layout_with_fr, vertex.label.cex=0.7) ``` -This already shows (roughly) the power-law structure that was already evident in [@dogesr]; however, looking at Figure 1 in that paper, we see that some families that were "excluded" if doges' parents are not included in the social network, are now part of the connected component. The Lando, Pasqualigo and Querini families were then "outside", and they are now linked through some matrilinear relationship. We'll check now which are the links in this case, as well as other that were also isolated previously. +This already shows the multi-center structure, with several strong families as nuclei, that was already evident in [@dogesr]; however, looking at Figure 1 in that paper, we see that some families that were "excluded" if doges' parents are not included in the social network, are now part of the connected component. The Lando, Pasqualigo and Querini families were then "outside", and they are now linked through some matrilinear relationship. We'll check now which are the links in this case, as well as other that were also isolated previously. ```{r newlinks} for (f in c("Pasqualigo","Foscari","Querini")) { diff --git a/vignettes/doges-split-social-network.Rmd b/vignettes/doges-split-social-network.Rmd new file mode 100644 index 0000000..13c1430 --- /dev/null +++ b/vignettes/doges-split-social-network.Rmd @@ -0,0 +1,60 @@ +--- +title: "Using `dogesr` to check Venetian social networks before and after the Serrata" +author: "JJ Merelo" +date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using `dogesr` to check Venetian social networks before and after the Serrata} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +bibliography: ../inst/doges.bib +--- + +```{r setup, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +## Introduction + +Using data from `dogesr` [@dogesr], we will, in this vignette, analyze the change of the social network before and after the *Serrata* [@serrata], revealed as a watershed event in the analysis performed in [@histories:jj] + +## Set up + +The Serrata mainly happened during the government of Pietro Gradenigo. We will then create two networks, one including that doge, the next one with all the others +```{r load, warning=FALSE,message=FALSE} +library(dogesr) +library(igraph) + +pre.serrata <- marriage.graph.slice(to="Pietro Gradenigo") +post.serrata <- marriage.graph.slice(from="Marino Zorzi") +``` + +This will call the function that creates, from raw data, the `igraph` data structure with which we can work. We still need to simplify them to be able to work with it. +```{r simplify} +weightify <- function( a.graph ) { + other.graph <- a.graph + E(other.graph)$weight <- 1 + other.graph <- simplify(other.graph, edge.attr.comb=list(weight="sum")) + return(other.graph) +} +pre.serrata <- weightify(pre.serrata) +post.serrata <- weightify(post.serrata) + +V(pre.serrata)$EV <- unname(unlist(eigen_centrality(pre.serrata)$vector)) +V(post.serrata)$EV <- unname(unlist(eigen_centrality(post.serrata)$vector)) +plot(pre.serrata,vertex.size=V(pre.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) +plot(post.serrata,vertex.size=V(post.serrata)$EV, layout=layout_nicely, vertex.label.cex=0.7) +``` + +The pre-Serrata graph is above, the post-serrata below. Before the Serrata, there were small (up to 4-5) sets of connected components, the biggest one the "star" around the Tiepolo family (which was an important part of the early XIV century rebellion); however, the Serrata had the effect of connecting the network, mainly because there were far many doges (as explained in [@histories:jj]), but also because marrying became an tactical move to increase the reach of the social network. + +It should be noted, however, that doges' marriages were but a small part of the complete social network; however, it is an important sample that, besides, shows who arrived to the summit of power (or servitude to the state, depending on how you look at it) + +## Conclusions + +Charting the doges social networks enables insights on the power and social dynamics of the Republic of Venice; being able to look at temporal slices is especially interesting since we can check how certain events influenced the social network. + +## References diff --git a/vignettes/doges-terms.Rmd b/vignettes/doges-terms.Rmd index 72a2ef3..79339b3 100644 --- a/vignettes/doges-terms.Rmd +++ b/vignettes/doges-terms.Rmd @@ -62,8 +62,8 @@ We can see whether this has any kind of influence using now several functions pr This can be analyzed a but further with a function provided by `dogesr`, `doges.years`. This filters part of the original data, leaving only data needed to work with the doges' terms (or years) ```{r using.doges.years} -doges.years.all <- doges.years() -knitr::kable(head(doges.years.all[order(-doges.years.all$Years),],10)) +data("doges.years") +knitr::kable(head(doges.years[order(-doges.years$Years),],10)) ``` First thing we can note is that, among the top 10, there is only one, Leonardo Loredan, who was elected after the aforementioned Francesco Foscari. This was, according to everyone, an unexpected event [@loredan], and he was chosen by the minimum needed to get elected. So he was really an outlier. The distribution in bins of 5 years, below, shows how infrequent was a term of more than 10 years. @@ -72,24 +72,24 @@ First thing we can note is that, among the top 10, there is only one, Leonardo L ```{r distribution, fig.cap="This histogram reproduces, with a fixed bin size, Figure 1 in [@smith2021long]."} library(ggplot2) -ggplot(doges.years.all, aes(x=Years))+geom_histogram(binwidth=5) +ggplot(doges.years, aes(x=Years))+geom_histogram(binwidth=5) ``` The distribution is skewed because it includes the first years of the institution. This is the distribution by centuries ```{r boxplot} -doges.years.all$Century <- as.factor(doges.years.all$Century) -ggplot(doges.years.all, aes(x=Century,y=Years))+geom_boxplot() +doges.years$Century <- as.factor(doges.years$Century) +ggplot(doges.years, aes(x=Century,y=Years))+geom_boxplot() ``` There seems to be a clear difference before and after the thirteenth century; there is also a return to longer tenures by the end of the Republic, in the 18th century. Was there a real difference? ```{r serrata} -doges.years.all$pre.serrata <- TRUE -doges.years.all[doges.years.all$Start >= 1297,]$pre.serrata <- FALSE -means <- aggregate(Years ~ pre.serrata, doges.years.all, mean) -medians <- aggregate(Years ~ pre.serrata, doges.years.all, median) -ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ +doges.years$pre.serrata <- TRUE +doges.years[doges.years$Start >= 1297,]$pre.serrata <- FALSE +means <- aggregate(Years ~ pre.serrata, doges.years, mean) +medians <- aggregate(Years ~ pre.serrata, doges.years, median) +ggplot(doges.years, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ stat_summary(fun=mean, geom="point", shape=20, size=3, color="red", fill="red") + geom_text(data = means, aes(label = round(Years, 2), y = Years + 2), size = 3) + geom_text(data = medians, aes(label = round(Years, 2), y = Years - 1), size = 3) @@ -98,12 +98,12 @@ ggplot(doges.years.all, aes(x=pre.serrata, y=Years))+geom_boxplot(notch=T)+ This difference is significant, as indicated by the Wilcoxon test ```{r wilcox} -wilcox.test(doges.years.all[doges.years.all$pre.serrata == T,]$Years, doges.years.all[doges.years.all$pre.serrata == F,]$Years ) +wilcox.test(doges.years[doges.years$pre.serrata == T,]$Years, doges.years[doges.years$pre.serrata == F,]$Years ) ``` ## Conclusions -As indicated by [@smith2021long], there seems to be evidence in the term limits of doges of the Republic of Venice. In their paper they indicate 1172 as a departure point for the term "limits", when the Maggior Consiglio was formed. According to the figure above, there does not seem to be a significant difference between the XII and XIII century in terms of tenure. However, 1297 does seem to be a watershed event, with all terms after that being significantly different to terms prior to it. We can conclude, then, that the Serrata, closing of the Maggior Consiglio to all but a few patrician families, was in fact the event that marked the shift to electing older doges. +As indicated by [@smith2021long], there seems to be evidence that supports the existence of "informal" limits on the terms of doges of the the Republic of Venice. In their paper they indicate 1172 as a departure point for the term "limits", when the Maggior Consiglio was formed. According to the figure above, there does not seem to be a significant difference between the XII and XIII century in terms of tenure. However, 1297 does seem to be a watershed event, with all terms after that being significantly different to terms prior to it. We can conclude, then, that the Serrata, closing of the Maggior Consiglio to all but a few patrician families, was in fact the event that marked the shift to electing older doges. This vignette also shows how, using `dogesr`, it becomes significantly easier for everyone with the skill to work with the R language to reproduce or work upon results related to life terms and other Venetian doges data.

6768 Francesco Foscari 15 142324
4445 Pietro Ziani 13 120523
5152 Pietro Gradenigo 13 128920
4546 Jacopo Tiepolo 13 122920
7778 Leonardo Loredan 16 1501