-
Notifications
You must be signed in to change notification settings - Fork 0
/
oa_patents.Rmd
52 lines (39 loc) · 968 Bytes
/
oa_patents.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
---
output: github_document
---
### Call Big Query
```{r, message = FALSE}
library(tidyverse)
library(DBI)
library(bigrquery)
con <- DBI::dbConnect(
bigrquery::bigquery(),
project = "api-project-764811344545"
)
```
### Unapywall match
Hosted on UGOE Big Query. See here for more details:
<https://doi.org/10.18452/22728>
Create table on Google Big Query
```{sql, connection=con}
CREATE TABLE tmp.patent_unpaywall_matched AS
SELECT *
FROM `api-project-764811344545.oadoi_full.upw_Jul21_08_21` AS `TBL_LEFT`
WHERE EXISTS (
SELECT 1 FROM `api-project-764811344545.tmp.patent_dois` AS `TBL_RIGHT`
WHERE (LOWER(`TBL_LEFT`.`doi`) = LOWER(`TBL_RIGHT`.`doi_cleaned`))
)
```
Fetch data
```{sql connection=con, output.var="oa_patents"}
SELECT *
FROM `api-project-764811344545.tmp.patent_unpaywall_matched`
```
```{r}
oa_patents
```
Local backup
```{r}
library(jsonlite)
jsonlite::stream_out(oa_patents, file("data/oa_patents.json"), verbose = FALSE)
```