-
Notifications
You must be signed in to change notification settings - Fork 0
/
snowball.qmd
202 lines (167 loc) · 3.89 KB
/
snowball.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
title: "Snowball Search and global quantification of the references"
format:
html:
toc: true
toc-depth: 2
embed-resources: true
code-fold: true
code-summary: "Show the code"
---
# Setup
```{r}
#| label: setup
#|
# library(bibtex)
library(openalexR)
library(writexl)
library(tibble)
library(dplyr)
library(ggplot2)
library(ggraph)
library(tidygraph)
library(knitr)
list.files(
"R",
full.names = TRUE,
recursive = TRUE
) |>
sapply(
FUN <- source
)
kp <- read.csv("./key_papers.csv")
kp <- split(kp, kp$ro)
```
# Searches
## OpenAlex
### Setup OpelAnex usage and do snowball serarch
```{r}
#| label: openalex_prep
#|
key_works <- lapply(
kp,
function(x) {
oa_fetch(
entity = "works",
doi = x$doi,
verbose = FALSE
)
}
)
saveRDS(key_works, "key_works.rds")
ids <- lapply(
key_works,
function(x){
openalexR:::shorten_oaid(x$id)
}
)
fn <- file.path(".", "data", "snowball.rds")
if (file.exists(fn)) {
snowball <- readRDS(fn)
} else {
snowball <- lapply(
ids,
function(x) {
oa_snowball(
identifier = x,
verbose = FALSE
)
}
)
saveRDS(snowball, fn)
}
flat_snow <- lapply(
snowball,
function(x){
snowball2df(x) |>
as_tibble()
}
)
```
### Save snowball as Excel file (`snowball_excel.xlsx`)
```{r}
#| label: openalex_excel
#|
###
lapply(
names(snowball),
function(x) {
fn <- file.path(".", "data", paste0(x, ".xlsx"))
to_xlsx(
snowball = snowball[[x]],
flat_snow = flat_snow[[x]],
xls_filename = fn
)
}
)
```
The column are: (the Concept columns are not that relevant at the moment)
- **id**: internal id fromOpenAlex
- **author**: authors of the paper
- **publication_year**: publication year
- **title**: title of the paper
- **doi**: doi of the paper
- **no_referenced_works**: number of references in the paper which are also in OpenAlex
- **cited_global**: Number of times the paper has been cited
- **cited_global_per_year**: standardised number of times cirted (cited_global / number of years published)
- **no_connections**: number of connections in the rgaph, i.e. either cited or citing a paper in the snowball corpus
- **concepts_l0**: Concept 0. level assigned by OpenAlex
- **concepts_l1**: Concept 1. level assigned by OpenAlex
- **concepts_l2**: Concept 2. level assigned by OpenAlex
- **concepts_l3**: Concept 3. level assigned by OpenAlex
- **concepts_l4**: Concept 4. level assigned by OpenAlex
- **concepts_l5**: Concept 5. level assigned by OpenAlex
- **author_institute**: Institute of the authors
- **institute_country**: Country of the institute
- **abstract**: the abstract of the paper
### Graph of links between references
```{r}
#| label: openalex_graph
#|
lapply(
names(snowball),
function(x){
plot_snowball(
snowball[[x]],
name = x
)
}
)
```
### Identification of references with more than one edge
This is the number of connections (`connection_count)`of the paper (`id`)
```{r}
#| label: openalex_edgecount
#|
mult_edge <- lapply(
flat_snow,
function(flat_snow) {
mult_edge <- flat_snow |>
select(id, connection_count) |>
filter(connection_count > 1) |>
arrange(desc(connection_count))
}
)
links <- lapply(
names(flat_snow),
function(x) {
flat_snow[[x]] |>
filter(id %in% mult_edge[[x]]$id)
}
)
lapply(
links,
function(links) {
links |>
select(id, display_name, publication_year, doi, connection_count) |>
arrange(desc(connection_count)) |>
knitr::kable()
}
)
```
# Finalize
To convert to pdf run e.g.
```{bash}
#| eval: false
wkhtmltopdf snowball.html snowball.pdf
```