Skip to content

Commit

Permalink
Add Graphs for general snowball search
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrug committed May 24, 2024
1 parent 3fa0c0e commit dec6841
Show file tree
Hide file tree
Showing 15 changed files with 83,931 additions and 43 deletions.
82,162 changes: 82,162 additions & 0 deletions IPBES_TCA_Ch3_clusters.html

Large diffs are not rendered by default.

185 changes: 154 additions & 31 deletions snowball.qmd → IPBES_TCA_Ch3_clusters.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ params:
gdm_path: !expr file.path('data', 'gdm')
---

# Back to [Readme](https://IPBES-Data.github.io/IPBES_BBA_Ch4_Snowball_Pilot_1/)

Waiting for new key-papers

# Setup
```{r}
#| label: setup
#|
if (!exists("params")) {
params <- rmarkdown::yaml_front_matter("snowball.qmd")$params
params <- rmarkdown::yaml_front_matter("IPBES_TCA_Ch3_clusters.qmd")$params
}
knitr::opts_chunk$set(message = NA)
Expand All @@ -36,11 +33,14 @@ library(IPBES.R)
library(openalexR)
library(dplyr)
library(readxl)
library(arrow)
library(tibble)
# library(dplyr)
# library(knitr)
library(networkD3)
library(webshot)
library(tictoc)
library(patchwork)
Expand Down Expand Up @@ -110,6 +110,15 @@ cluster <- lapply(
)
names(cluster) <- paste0("cluster_", 1:6)
approach_colors <- c(
"#D46746",
"#E69A6A",
"#E6C540",
"#B5C788",
"#2DB3B0",
"#A693B5"
)
```

# Verification of key papers
Expand Down Expand Up @@ -370,6 +379,43 @@ toc()

# Create Graphs

## Create Static Citation Network Graph of the General Corpus

```{r}
#| label: openalex_graph
## | |
no <- list.files("figures", pattern = "snowball_cited", full.names = TRUE) |>
length()
if (no < 4) {
snowball <- file.path("data", "snowball.rds") |>
readRDS()
key_works_au <- file.path("data", "key_works.rds") |>
readRDS() |>
IPBES.R::abbreviate_authors()
key_works_id <- names(key_works_au)
key_works_cit <- Map(function(au, id) c(cit = au, id = id), key_works_au, key_works_id)
names(key_works_cit) <- NULL
snowball$nodes$cited_by_count_by_year <- snowball$nodes$cited_by_count / (2024 - snowball$nodes$publication_year)
snowball_p <- snowball
for (i in seq_along(key_works_cit)) {
snowball_p$nodes$id[snowball_p$nodes$id %in% key_works_cit[[i]]["id"]] <- key_works_cit[[i]]["cit"]
snowball_p$edges$from[snowball_p$edges$from %in% key_works_cit[[i]]["id"]] <- key_works_cit[[i]]["cit"]
snowball_p$edges$to[snowball_p$edges$to %in% key_works_cit[[i]]["id"]] <- key_works_cit[[i]]["cit"]
}
IPBES.R::plot_snowball(snowball_p, name = "snowball", path = "figures")
rm(snowball_p)
}
```

## Create Static Citation Network Graph of the S1 Corpus

Only S1 corpus of S1 can be graphed due to the size of the S2 corpus.
Expand Down Expand Up @@ -594,6 +640,35 @@ toc()


# Results

## Network Graph of General Snowball Search

![Cited by count](figures/snowball_cited_by_count.png)

To download the highres graph, please [click here](figures/snowball_cited_by_count.pdf).

```{r}
#| label: general_snowball_nodes_data
#|
data <- readRDS(file.path("data", "snowball.rds"))[["nodes"]]
data$author_abbr <- IPBES.R::abbreviate_authors(data)
data$doi <- paste0("<a href=\'", data$doi, "\' target='_blank'>", gsub("https://doi.org/", "", data$doi), "</a>")
data |>
dplyr::select(
id,
doi,
author_abbr,
title,
cited_by_count,
ab
) |>
IPBES.R::table_dt()
```

## Graphs and Maps

The following interactions are possible in the interactive graphs:
Expand Down Expand Up @@ -825,7 +900,7 @@ plot_chord <- function(
"cluster_2" ~ "Knowledge co-creation",
"cluster_3" ~ "Systems",
"cluster_4" ~ "Inner Transformation",
"cluster_5" ~ "Empowerrment",
"cluster_5" ~ "Empowerment",
"cluster_6" ~ "Structural"
)
colnames(m) <- dplyr::case_match(
Expand All @@ -834,18 +909,18 @@ plot_chord <- function(
"cluster_2" ~ "Knowledge co-creation",
"cluster_3" ~ "Systems",
"cluster_4" ~ "Inner Transformation",
"cluster_5" ~ "Empowerrment",
"cluster_5" ~ "Empowerment",
"cluster_6" ~ "Structural"
)
groupColors <- c(
"#D46746",
"#E69A6A",
"#E6C540",
"#B5C788",
"#2DB3B0",
"#A693B5"
)
# groupColors <- c(
# "#D46746",
# "#E69A6A",
# "#E6C540",
# "#B5C788",
# "#2DB3B0",
# "#A693B5"
# )
# groupColors <- c(
# grDevices::rgb(red = .87, green = 0.45, blue = 0.33),
Expand All @@ -862,7 +937,7 @@ plot_chord <- function(
showTicks = showTicks,
type = "directional", ,
margin = margin,
groupColors = groupColors,
groupColors = approach_colors,
...
)
return(cd)
Expand Down Expand Up @@ -972,6 +1047,14 @@ nodes <- data.frame(
data$Theory |> unique()
)
)
nodes$group <- c(
paste0(1:6, "."),
rep(
"theory",
nrow(nodes) - length(approach_colors)
)
)
links <- lapply(
2:7,
Expand Down Expand Up @@ -1002,45 +1085,85 @@ links <- lapply(
as.numeric(),
target = as.numeric(target) - 1,
value = 1
) |>
dplyr::filter(
!is.na(level)
)
library(networkD3)
library(webwidgets)
library(webshot)
links$level <- as.character(links$level)
my_color <- 'd3.scaleOrdinal() .domain(["1", "2", "1.", "2.", "3.", "4.", "5.", "6.", "theory"]) .range(["red", "blue", "#D46746", "#E69A6A", "#E6C540", "#B5C788", "#2DB3B0", "#A693B5", "lightgrey"])'
##########
bn <- file.path("figures", "approaches_theories_1")
sankeyNetwork(
Links = links |> dplyr::filter(level == 1),
LinkGroup = "level",
Nodes = nodes,
Source = "source",
Target = "target",
NodeGroup = "group",
Source = "target",
Target = "source",
Value = "value",
NodeID = "name"
NodeID = "name",
colourScale = my_color,
sinksRight = FALSE
) |>
htmlwidgets::saveWidget(
file = paste0(bn, ".html"),
selfcontained = TRUE
saveNetwork(
file = paste0(bn, ".html"),
selfcontained = TRUE
)
webshot::webshot(
url = paste0(bn, ".html"),
file = paste0(bn, ".pdf")
)
unlink(paste0(bn, "_files"), recursive = TRUE)
##########
bn <- file.path("figures", "approaches_theories_2")
sankeyNetwork(
Links = links |> dplyr::filter(level == 2),
LinkGroup = "level",
Nodes = nodes,
NodeGroup = "group",
Source = "target",
Target = "source",
Value = "value",
NodeID = "name",
colourScale = my_color,
sinksRight = FALSE
) |>
saveNetwork(
file = paste0(bn, ".html"),
selfcontained = TRUE
)
webshot::webshot(
url = paste0(bn, ".html"),
file = paste0(bn, ".pdf")
)
unlink(paste0(bn, "_files"), recursive = TRUE)
bn <- file.path("figures", "approaches_theories_1_2")
sankeyNetwork(
Links = links |> dplyr::filter(!is.na(level)),
LinkGroup = "level",
Nodes = nodes,
Source = "source",
Target = "target",
NodeGroup = "group",
Source = "target",
Target = "source",
Value = "value",
NodeID = "name"
NodeID = "name",
colourScale = my_color,
sinksRight = FALSE
) |>
htmlwidgets::saveWidget(
file = paste0(bn, ".html"),
selfcontained = TRUE
)
saveNetwork(
file = paste0(bn, ".html"),
selfcontained = TRUE
)
unlink(paste0(bn, "_files"), recursive = TRUE)
webshot::webshot(
url = paste0(bn, ".html"),
file = paste0(bn, ".pdf")
Expand Down
Binary file modified data/key_works.rds
Binary file not shown.
6 changes: 3 additions & 3 deletions figures/approaches_theories_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -1595,9 +1595,9 @@
</head>
<body style="background-color: white;">
<div id="htmlwidget_container">
<div class="sankeyNetwork html-widget html-fill-item" id="htmlwidget-b5449b79367c98b1436d" style="width:960px;height:500px;"></div>
<div class="sankeyNetwork html-widget html-fill-item" id="htmlwidget-9b001fb975a7624fcf93" style="width:960px;height:500px;"></div>
</div>
<script type="application/json" data-for="htmlwidget-b5449b79367c98b1436d">{"x":{"links":{"source":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],"target":[6,7,45,61,7,9,10,11,13,33,42,49,59,66,67,8,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,45,52,31,42,48,54,55,56,57,59,65,12,30,32,33,34,46,47,54,58,65,27,35,36,37,38,39,40,41,43,44,49,50,51,53,60,62,63,64],"value":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]},"nodes":{"name":["1 Science and Technology","2. Knowledge co-creation","3. Systems","4. Inner Transformation","5. Empowerment","6. Structural","Epistemic communities","Inclusive Innovation","Value-centred leverage points to catalyse transformative change","Three Horizons","Ethnoecology","Transformative sustainability science ","Environmental History : Environmentalism of the Poors and Environmental Coloniality","Participatory research","Human Agency","Agroecological Transformations","Phases of deliberate social-ecological transformations","Panarchy Theory","Catalyzing Transformation","Seeds of Good Anthropocenes","Collective action in social-ecological systems","Integrative framework for transformative social change","Sustainability transitions","Social movements theories","Transition Governance","Leverage points for sustainability transformation","Transformation Flower Approach as a theory of change","Transition management","Metatheories of human action","Redesigning Theories of Change","Praxis ","Pathways to Nature Connectedness","Political ecology","Transformative Spaces","Three Spheres of Transformation","Karl Polanyi's The Great Transformation","Marxist theory","Rational choice theory ","Institutional analysis","Ecological Civilization Framework ","Governmentality ","Degrowth and Post-growth Studies","Transformative Education","Strengthening Accountability Frameworks","Biodiversity Policy Integration BPI","Sociotechnical infraestructures","Fractal Agency","Decolonial Feminisms and Ecofeminisms ","Transformative Learning for Socio-Ecological Sustainability","Transformative Innovation Policy","Behavioral Economics","Actor Network Theory (ANT)","Regenerative approaches ","International political economy","Inner Transformation","Relationality","SHIFT","Regenerative dialogues for sustainable futures","Everyday Resistance","Relational values and Relationality","Transformative governance","Technological and scientific constructivism","Environmental State and the Green State","Structuration Theory","Social Practice Theory","Feminist political ecology ","Local Biodiversity Outlook (LBO) transitions","Transdisciplinary research"],"group":["1 Science and Technology","2. Knowledge co-creation","3. Systems","4. Inner Transformation","5. Empowerment","6. Structural","Epistemic communities","Inclusive Innovation","Value-centred leverage points to catalyse transformative change","Three Horizons","Ethnoecology","Transformative sustainability science ","Environmental History : Environmentalism of the Poors and Environmental Coloniality","Participatory research","Human Agency","Agroecological Transformations","Phases of deliberate social-ecological transformations","Panarchy Theory","Catalyzing Transformation","Seeds of Good Anthropocenes","Collective action in social-ecological systems","Integrative framework for transformative social change","Sustainability transitions","Social movements theories","Transition Governance","Leverage points for sustainability transformation","Transformation Flower Approach as a theory of change","Transition management","Metatheories of human action","Redesigning Theories of Change","Praxis ","Pathways to Nature Connectedness","Political ecology","Transformative Spaces","Three Spheres of Transformation","Karl Polanyi's The Great Transformation","Marxist theory","Rational choice theory ","Institutional analysis","Ecological Civilization Framework ","Governmentality ","Degrowth and Post-growth Studies","Transformative Education","Strengthening Accountability Frameworks","Biodiversity Policy Integration BPI","Sociotechnical infraestructures","Fractal Agency","Decolonial Feminisms and Ecofeminisms ","Transformative Learning for Socio-Ecological Sustainability","Transformative Innovation Policy","Behavioral Economics","Actor Network Theory (ANT)","Regenerative approaches ","International political economy","Inner Transformation","Relationality","SHIFT","Regenerative dialogues for sustainable futures","Everyday Resistance","Relational values and Relationality","Transformative governance","Technological and scientific constructivism","Environmental State and the Green State","Structuration Theory","Social Practice Theory","Feminist political ecology ","Local Biodiversity Outlook (LBO) transitions","Transdisciplinary research"]},"options":{"NodeID":"name","NodeGroup":"name","LinkGroup":null,"colourScale":"d3.scaleOrdinal(d3.schemeCategory20);","fontSize":7,"fontFamily":null,"nodeWidth":15,"nodePadding":10,"units":"","margin":{"top":null,"right":null,"bottom":null,"left":null},"iterations":32,"sinksRight":true}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-b5449b79367c98b1436d">{"viewer":{"width":450,"height":350,"padding":10,"fill":true},"browser":{"width":960,"height":500,"padding":10,"fill":true}}</script>
<script type="application/json" data-for="htmlwidget-9b001fb975a7624fcf93">{"x":{"links":{"source":[6,7,45,61,7,9,10,11,13,33,42,49,59,66,67,8,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,45,52,31,42,48,54,55,56,57,59,65,12,30,32,33,34,46,47,54,58,65,27,35,36,37,38,39,40,41,43,44,49,50,51,53,60,62,63,64],"target":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],"value":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"group":["1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"]},"nodes":{"name":["1 Science and Technology","2. Knowledge co-creation","3. Systems","4. Inner Transformation","5. Empowerment","6. Structural","Epistemic communities","Inclusive Innovation","Value-centred leverage points to catalyse transformative change","Three Horizons","Ethnoecology","Transformative sustainability science ","Environmental History : Environmentalism of the Poors and Environmental Coloniality","Participatory research","Human Agency","Agroecological Transformations","Phases of deliberate social-ecological transformations","Panarchy Theory","Catalyzing Transformation","Seeds of Good Anthropocenes","Collective action in social-ecological systems","Integrative framework for transformative social change","Sustainability transitions","Social movements theories","Transition Governance","Leverage points for sustainability transformation","Transformation Flower Approach as a theory of change","Transition management","Metatheories of human action","Redesigning Theories of Change","Praxis ","Pathways to Nature Connectedness","Political ecology","Transformative Spaces","Three Spheres of Transformation","Karl Polanyi's The Great Transformation","Marxist theory","Rational choice theory ","Institutional analysis","Ecological Civilization Framework ","Governmentality ","Degrowth and Post-growth Studies","Transformative Education","Strengthening Accountability Frameworks","Biodiversity Policy Integration BPI","Sociotechnical infraestructures","Fractal Agency","Decolonial Feminisms and Ecofeminisms ","Transformative Learning for Socio-Ecological Sustainability","Transformative Innovation Policy","Behavioral Economics","Actor Network Theory (ANT)","Regenerative approaches ","International political economy","Inner Transformation","Relationality","SHIFT","Regenerative dialogues for sustainable futures","Everyday Resistance","Relational values and Relationality","Transformative governance","Technological and scientific constructivism","Environmental State and the Green State","Structuration Theory","Social Practice Theory","Feminist political ecology ","Local Biodiversity Outlook (LBO) transitions","Transdisciplinary research"],"group":["1.","2.","3.","4.","5.","6.","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory","theory"]},"options":{"NodeID":"name","NodeGroup":"group","LinkGroup":"level","colourScale":"d3.scaleOrdinal() .domain([\"1\", \"2\", \"1.\", \"2.\", \"3.\", \"4.\", \"5.\", \"6.\", \"theory\"]) .range([\"red\", \"blue\", \"#D46746\", \"#E69A6A\", \"#E6C540\", \"#B5C788\", \"#2DB3B0\", \"#A693B5\", \"lightgrey\"])","fontSize":7,"fontFamily":null,"nodeWidth":15,"nodePadding":10,"units":"","margin":{"top":null,"right":null,"bottom":null,"left":null},"iterations":32,"sinksRight":false}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-9b001fb975a7624fcf93">{"viewer":{"width":450,"height":350,"padding":10,"fill":true},"browser":{"width":960,"height":500,"padding":10,"fill":true}}</script>
</body>
</html>
Binary file modified figures/approaches_theories_1.pdf
Binary file not shown.
Loading

0 comments on commit dec6841

Please sign in to comment.