connect.Rmd
{manyenviron}
stores several datasets on various aspects of environmental treaties in different databases. For example, the Agreements database is made of multiple datasets of environmental treaty titles with specific information such as the agreement type (e.g. agreements, protocols, amendments, declarations), if they are bilateral or multilateral, and some important dates such as the signature or entry into force. The Memberships database contains lists of countries with the treaties to which they are parties to. It also includes information on the signature date of the treaty or the withdrawal date of a party. The References database is composed of a dataset that indicates the relationship (e.g. amended by, cites, superseded by) between two treaties. Finally, the Texts database stores the text of environmental treaties.
For a quick overview of the database and dataset in {manyenviron}
, we can use the data_contrast()
function from manydata.
library(manydata)
manydata::data_contrast("manyenviron", "agreements", "IEADB")
manydata::data_contrast("manyenviron", "memberships")
To view the bibliographic references for a dataset, a database, or the whole package, we can also use code_source()
from manydata.
manydata::data_source("manyenviron", "agreements", "IEADB")
manydata::data_source("manyenviron", "memberships")
manydata::data_source("manyenviron")
There are many different ways in which treaties could be linked. For example, a treaty can be substituted by another, complemented by protocols, changed through amendments, and/or cite another treaty. To facilitate the identification and connection between the databases in the package, the manypkgs::code_agreements()
function has been developed to generate a treatyID for treaties in a database. Each of the {manyenviron}
dataset contains a treatyID column. To understand what are the information provided through by the treatyID, as well as the benefits of using treatyID to spot the relationships between the treaties across several datasets in a database, please visit this article on the {manypkgs}
website.
Below are two examples of how to visualise treaty linkages for the references and the memberships databases in {manyenviron}
. We use migraph to create the network plots, more information about the package can be found here.
The graph below illustrates a sample of earliest 25 treaties from the references database. We select only treaties that cite other treaties. The treatyIDs are used to facilitate the reading and illustration of the relationships.
library(dplyr)
library(ggplot2)
library(migraph)
library(stringr)
# Get dataset
references <- manyenviron::references$ECOLEX_REF %>%
dplyr::distinct() %>%
dplyr::mutate(year = stringr::str_extract(treatyID2, "[:digit:]{4}")) %>%
dplyr::filter(RefType == "Cites") %>%
dplyr::arrange(year)
# Plot with migraph
migraph::gglineage(references[1:25, c(1, 2, 3)]) +
labs(title = "Treaty Lineage of Selected Agreements",
caption = "Source: manyenviron") +
theme(plot.title = element_text(family = "sans",
size = 18,
hjust = 0.5))
#>
#> The downloaded binary packages are in
#> /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpIgn2Rp/downloaded_packages
We can also take a look at a single lineage of Enviromental treaties. Let’s look at treaties that either cite or ammend the Ramsar Convention on Wetlands of International Importance Especially as Waterfowl Habitat (“RAMSA_1971A”).
# Subset dataset
ramsa <- manyenviron::references$ECOLEX_REF %>%
dplyr::distinct() %>%
dplyr::mutate(year = stringr::str_extract(treatyID2, "[:digit:]{4}")) %>%
dplyr::filter(treatyID2 == "RAMSA_1971A") %>%
dplyr::arrange(year)
# Get agreement titles, join information, and plot
manyenviron::agreements$ECOLEX %>%
dplyr::select(Title, treatyID) %>%
dplyr::rename(treatyID1 = treatyID) %>%
dplyr::right_join(ramsa) %>%
dplyr::rename(to = treatyID2,
from = Title) %>%
dplyr::select(to, from, RefType) %>%
migraph::as_tidygraph() %>%
migraph::activate(edges) %>%
migraph::autographr(edge_color = "RefType")
The graph below illustrates the connection between parties and treaties for multilateral environmental agreements signed into force in 1980 using the memberships database.
# Subset and plot data
manyenviron::memberships$IEADB_MEM %>%
dplyr::mutate(year = stringr::str_extract(manyID, "[:digit:]{4}")) %>%
dplyr::filter(year == "1980") %>%
dplyr::select(treatyID, stateID, year) %>%
group_by(treatyID) %>%
filter( n() > 2) %>% # keep only multilateral treaties
migraph::as_tidygraph() %>%
migraph::activate(nodes) %>%
dplyr::mutate(color = ifelse(grepl("_", name), 1, 0),
size = ifelse(grepl("_", name), 4, 2),
shape = ifelse(grepl("_", name), "square", "circle")) %>%
migraph::to_undirected() %>%
migraph::autographr(node_color = "color", node_size = "size",
node_shape = "shape")
For events or panel network data, migraph allows users to visualise how networks evolve over time as animations.
# Install the development version of migraph, for now
remotes::install_github("snlab-ch/migraph", ref = "develop")
# Subset and plot data
manyenviron::memberships$IEADB_MEM %>%
dplyr::mutate(year = stringr::str_extract(manyID, "[:digit:]{4}")) %>%
dplyr::filter(year == "1980" | year == "1981") %>%
dplyr::select(treatyID, stateID, year) %>%
group_by(treatyID) %>%
filter( n() > 2) %>% # keep only multilateral treaties
migraph::as_tidygraph() %>%
migraph::activate(nodes) %>%
dplyr::mutate(color = ifelse(grepl("_", name), "blue", "red"),
size = ifelse(grepl("_", name), 4, 2),
shape = ifelse(grepl("_", name), "square", "circle")) %>%
migraph::to_waves(attribute = "year") %>%
migraph::autographd(delete.vertices = TRUE, node_color = "color",
node_size = "size", node_shape = "shape")