Setup
Internal code for setup of the snowball search.
Show the code
library (bibtex)
library (openalexR)
Thank you for using openalexR!
To acknowledge our work, please cite the package by calling `citation("openalexR")`.
To suppress this message, add `openalexR.message = suppressed` to your .Renviron file.
Show the code
library (writexl)
library (tibble)
library (dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Show the code
Loading required package: ggplot2
Show the code
Attaching package: 'tidygraph'
The following object is masked from 'package:stats':
filter
Show the code
if (! require ("IPBES.R" )){
install.packages (
"IPBES.R" ,
repos = c ('https://ipbes-data.r-universe.dev' , 'https://cloud.r-project.org' )
)
}
Loading required package: IPBES.R
Warning: replacing previous import 'DT::JS' by 'networkD3::JS' when loading
'IPBES.R'
Show the code
# library(ggplot2)
# library(knitr)
kp <- bibtex:: read.bib ("./key-paper.bib" )
dois <- sapply (
kp,
function (x) {
x$ doi
}
)
Searches
Searches are conducted with the OpenAlex API. The API is documented here .
Setup OpenAlex usage and do snowball serarch
Show the code
fn <- file.path ("data" , "key_works.rds" )
if (exists (fn)){
key_works <- readRDS (fn)
} else {
key_works <- oa_fetch (
entity = "works" ,
doi = dois,
verbose = FALSE
)
}
ids <- openalexR::: shorten_oaid (key_works$ id)
fn <- file.path ("data" , "snowball.rds" )
if (file.exists (fn)) {
snowball <- readRDS (fn)
} else {
snowball <- oa_snowball (
identifier = ids,
verbose = FALSE
)
saveRDS (snowball, fn)
}
flat_snow <- snowball2df (snowball) |>
tibble:: as_tibble ()
key_works_cit <- list (
c (cit = "Fisher et al. 2022" , id = "W4220786370" ),
c (cit = "Patterson et al. 2017" , id = "W2520670351" ),
c (cit = "Feola et al. 2015" , id = "W2020319093" ),
c (cit = "Loorbach et al. 2017" , id = "W2204133637" ),
c (cit = "Scoones et al. 2020" , id = "W3001406994" ),
c (cit = "Evans et al. 2023" , id = "W4379647013" )
)
Supplemented edges between all papers
Show the code
fn <- file.path ("data" , "snowball_supplemented.rds" )
if (file.exists (fn)) {
snowball_supplemented <- readRDS (fn)
} else {
new_edges <- tibble (
from = character (0 ),
to = character (0 )
)
works <- snowball$ nodes$ id
for (i in 1 : nrow (snowball$ nodes)) {
from <- works[[i]]
to <- gsub ("https://openalex.org/" , "" , snowball$ nodes$ referenced_works[[i]])
to_in_works <- to[to %in% works]
if (length (to_in_works) > 0 ) {
new_edges <- add_row (
new_edges,
tibble (
from = from,
to = to_in_works
)
)
}
}
snowball_supplemented <- snowball
snowball_supplemented$ edges <- add_row (snowball_supplemented$ edges, new_edges) |>
distinct ()
saveRDS (snowball_supplemented, fn)
}
Results
Number of papers cited by keypapers
Show the code
x <- key_works_cit |>
simplify2array ()
keypapers <- x["cit" , ]
names (keypapers) <- x["id" , ]
rm (x)
snowball$ edges |>
filter (from %in% names (keypapers)) |>
unique () |>
mutate (
cit = unlist (keypapers[from])
) |>
select (cit) |>
table () |>
as.data.frame () |>
arrange (desc (Freq)) |>
knitr:: kable (
col.names = c ("Key paper" , "Number of papers" ),
caption = "Number of papers cited by Keypapers in the snowball search"
)
Number of papers cited by Keypapers in the snowball search
Loorbach et al. 2017
123
Patterson et al. 2017
75
Scoones et al. 2020
65
Feola et al. 2015
64
Fisher et al. 2022
57
Evans et al. 2023
55
Show the code
snowball$ edges |>
filter (to %in% names (keypapers)) |>
unique () |>
mutate (
cit = unlist (keypapers[to]),
) |>
select (cit) |>
table () |>
as.data.frame () |>
arrange (desc (Freq)) |>
knitr:: kable (
col.names = c ("Key paper" , "Number of papers" ),
caption = "No of papers citing the Keypapers in the snowball search"
)
No of papers citing the Keypapers in the snowball search
Loorbach et al. 2017
701
Patterson et al. 2017
495
Feola et al. 2015
398
Scoones et al. 2020
270
Fisher et al. 2022
16
Evans et al. 2023
2
Save snowball as Excel file
Show the code
fn <- file.path ("." , "data" , "snowball_excel.xlsx" )
if (! file.exists (fn)){
IPBES.R:: to_xlsx (snowball, fn)
}
To download the Excsl file with all references, plese click here .
Graph of links between references
Show the code
#|
no <- list.files ("figures" , pattern = "snowball_cited" , full.names = TRUE ) |>
length ()
if (no != 4 ){
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)
}