-
Notifications
You must be signed in to change notification settings - Fork 0
/
tdm_metadata.qmd
111 lines (100 loc) · 2.22 KB
/
tdm_metadata.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
---
title: "tdm_metadata"
format: gfm
---
```{r, setup, echo=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE,
echo = TRUE,
fig.width = 6,
fig.asp = 0.618,
out.width = "99%",
fig.align = "center",
dpi = 300,
dev = c("png", "pdf"),
fig.path = "fig/"
)
options(scipen = 999, digits = 2)
knitr::knit_hooks$set(
inline = function(x) {
if (is.numeric(x)) {
return(prettyNum(x, big.mark = ","))
} else{
return(x)
}
}
)
```
```{r deps}
library(bigrquery)
library(dplyr)
library(readr)
library(DBI)
```
## Connect to database
```{r BQ connection}
library(DBI)
library(bigrquery)
con <- dbConnect(
bigrquery::bigquery(),
project = "api-project-764811344545",
dataset = "cr_dump_march_20"
)
bq_auth()
```
## Get TDM metadata
Journal article volume by publisher since 2013 by
- Intended use of full-text link. `text-mining` highlights that a full-text link can be used for text and data mining through the publisher
- MIME Type of full-text provided by the publisher
- Open license. Note only the availability of a CC license was checked
```{sql connection=con, output.var="tdm_data"}
WITH
raw AS (
SELECT
link,
publisher,
license,
EXTRACT ( YEAR
FROM
issued ) AS cr_year,
doi,
fulltext_links,
CASE
WHEN REGEXP_CONTAINS(LOWER(license.url), "creativecommons.org") THEN "CC"
ELSE
NULL
END
AS open_license
FROM
`subugoe-collaborative.cr_instant.snapshot`,
UNNEST(link) AS fulltext_links,
UNNEST(license) AS license
WHERE
type = "journal-article" )
SELECT
COUNT(DISTINCT doi) AS n_articles, -- Number of articles
publisher, -- Publisher name, be aware of imprints
fulltext_links. intended_application, -- Intended use of full-text link
fulltext_links.content_type, -- MIME Type,
open_license -- Is there a CC license?
FROM
raw
WHERE
fulltext_links.intended_application IN ("text-mining",
"unspecified")
GROUP BY
publisher,
fulltext_links.content_type,
fulltext_links.intended_application,
open_license
ORDER BY
n_articles DESC
```
Glimpse and back up as csv
```{r backup}
tdm_data
write_csv(tdm_data, "tdm_md_crossref_journal_articles_since_2013.csv")
```