-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoa_exploration.Rmd
188 lines (161 loc) · 4.71 KB
/
oa_exploration.Rmd
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
---
output: github_document
---
```{r, setup, echo=FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE,
echo = TRUE,
fig.width = 6,
fig.asp = 0.618,
out.width = "70%",
fig.align = "center",
dpi = 300
)
options(scipen = 999, digits = 4)
knitr::knit_hooks$set(
inline = function(x) {
if (is.numeric(x)) {
return(prettyNum(x, big.mark = ","))
} else{
return(x)
}
}
)
library(tidyverse)
library(jsonlite)
```
## Data
Patents matched to Unpaywall via DOIs
```{r}
npl_df <- readr::read_csv("data/dois_to_be_checked.csv") %>%
mutate(doi = tolower(doi_cleaned))
oa_upy <- jsonlite::stream_in(file("data/oa_patents.json"), verbose = FALSE)
my_df <-
inner_join(npl_df, oa_upy, by = "doi")
my_df
```
## Exploratory data analysis
### Publication view
#### By publication type
```{r}
my_df %>%
group_by(genre) %>%
summarise(n = n_distinct(doi)) %>%
mutate(prop = n / sum(n)) %>%
arrange(desc(n)) %>%
knitr::kable()
```
#### By publication year (journal articles only)
```{r}
my_df %>%
filter(genre == "journal-article") %>%
group_by(year, is_oa) %>%
summarise(n = n_distinct(doi)) %>%
ggplot(aes(year, n, fill = is_oa, group = is_oa)) +
geom_area() +
scale_fill_manual(
values = c("#cccccca0", "#56b4e9"),
name = NULL,
labels = c("Closed", "Open Access")
) +
scale_y_continuous(expand = expansion(mult = c(0, 0.05)),
#limits = c(0, 8000)
) +
cowplot::theme_minimal_hgrid() +
labs(x = "Publication Year", y = "NPLs") +
theme(legend.position = "top",
legend.justification = "right")
```
#### OA by provider
Unpaywall distinguishes the provider of the open access full text, `publisher`
and `repository`.
```{r}
oa_df <- my_df %>%
filter(genre == "journal-article", is_oa == TRUE) %>%
unnest(oa_locations)
# overlap repo / publisher
host_cat <- oa_df %>%
distinct(doi, year, host_type, is_best, has_repository_copy) %>%
filter(is_best == TRUE) %>%
mutate(provider_cat = case_when(
host_type == "publisher" & has_repository_copy == TRUE ~ "Journal & Repository",
host_type == "repository" ~ "Repository only",
host_type == "publisher" ~ "Journal only"
)) %>%
group_by(provider_cat, year) %>%
summarise(n = n_distinct(doi))
# all years
all_year <- oa_df %>%
group_by(year) %>%
summarise(n = n_distinct(doi))
ggplot(host_cat, aes(x = year, y = n)) +
geom_bar(
data = all_year,
aes(fill = "All OA Articles"),
color = "transparent",
stat = "identity"
) +
geom_bar(aes(fill = "by Host"), color = "transparent", stat = "identity") +
facet_wrap( ~ provider_cat, nrow = 1) +
scale_fill_manual(values = c("#b3b3b3a0", "#56B4E9"), name = "") +
scale_y_continuous(
labels = scales::number_format(big.mark = ","),
expand = expansion(mult = c(0, 0.05))) +
labs(x = "Publication Year", y = "OA Articles") +
theme(legend.position = "top", legend.justification = "right") +
cowplot::theme_minimal_hgrid() +
theme(legend.position = "top",
legend.justification = "right")
```
#### OA by Unpaywall OA color
```{r}
oa_df %>%
group_by(oa_status) %>%
summarise(n = n_distinct((doi))) %>%
mutate(prop = n / length(unique(oa_df$doi))) %>%
arrange(desc(n)) %>%
knitr::kable()
```
### Patent view
#### Lag patent and npl publication date
```{r}
my_df %>%
filter(genre == "journal-article") %>%
select(doi, publication_date, country_code, year) %>%
mutate(npl_year = substr(publication_date, 1, 4)) %>%
mutate(lag = as.integer(npl_year) - as.integer(year)) %>%
ggplot(aes(x = lag)) +
geom_histogram(stat = "count", fill="#56B4E9") +
geom_vline(aes(xintercept = median(lag, na.rm = T)),
colour = "#E69F00", linetype ="dashed", size = .8) +
cowplot::theme_minimal_hgrid() +
scale_y_continuous(expand = expand_scale(mult = c(0, 0.05))) +
labs(y = "NPL", x = " Lag between patent issued year and npl publication year")
```
#### OA by patent office
Only US vs European Patent Office (EP)
```{r}
my_df %>%
mutate(npl_year = substr(publication_date, 1, 4)) %>%
# only us vs ep
filter(country_code %in% c("US", "EP")) %>%
group_by(is_oa, country_code, npl_year) %>%
summarise(n = n_distinct(doi)) %>%
ggplot(aes(as.integer(npl_year), n, fill = is_oa)) +
geom_bar(stat = "identity") +
scale_fill_manual(
values = c("#cccccca0", "#56b4e9"),
name = NULL,
labels = c("Closed", "Open Access")
) +
scale_x_continuous(limits = c(2008, 2022)) +
scale_y_continuous(expand = expansion(mult = c(0, 0.05))) +
facet_wrap(~country_code) +
cowplot::theme_minimal_hgrid() +
labs(x = "Patent Issued Year", y = "NPLs") +
theme(legend.position = "top",
legend.justification = "right")
```