Last active
March 5, 2019 21:18
-
-
Save njahn82/e5a4beed4f21262faf762b854459db76 to your computer and use it in GitHub Desktop.
Unpaywall evidence type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' bq unpaywall dump | |
| #' | |
| #' connect to google bg with imported jsonl Unpaywall dump | |
| library(DBI) | |
| library(tidyverse) | |
| library(bigrquery) | |
| con <- dbConnect( | |
| bigrquery::bigquery(), | |
| project = "api-project-764811344545", | |
| dataset = "oadoi_full" | |
| ) | |
| #' connection | |
| oadoi <- tbl(con, "mongo_13_sep_18") | |
| #' query (SQL) | |
| my_query <- c("SELECT evidence, is_best, year, COUNT(*) AS number_of_articles | |
| FROM `oadoi_full.mongo_13_sep_18`, UNNEST(oa_locations) | |
| GROUP BY evidence, year, is_best") | |
| #' call bq | |
| dbGetQuery(con, my_query) -> my_evidence | |
| #' plot | |
| my_evidence %>% | |
| filter(year %in% 2013:2018) %>% | |
| ggplot(aes(factor(year), number_of_articles, fill = is_best)) + | |
| geom_bar(stat = "identity") + | |
| facet_wrap(~evidence, ncol = 3) + | |
| scale_y_continuous( | |
| labels = function(x) | |
| format(x, big.mark = " ", scientific = FALSE), | |
| breaks = scales::pretty_breaks() | |
| ) + | |
| scale_fill_manual( | |
| values = c("#23445D","#AE4132") | |
| ) + | |
| theme_minimal() + | |
| labs(x = "Year", y = "Articles", title = "Unpaywall OA evidence categories per year") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment