Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karthik/preprint-count
https://github.com/karthik/preprint-count
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/karthik/preprint-count
- Owner: karthik
- Created: 2018-07-07T04:18:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-09T17:50:19.000Z (over 6 years ago)
- Last Synced: 2024-10-13T19:10:09.069Z (3 months ago)
- Homepage:
- Size: 735 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
title: "Papers with preprints"
author: "Karthik Ram & Jennifer Lin"
date: "7/6/2018"
output: md_document
---```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
``````{r, echo = FALSE, warning=FALSE}
suppressPackageStartupMessages(library(tidyverse, warn.conflicts = FALSE, quietly = TRUE))
suppressPackageStartupMessages(library(rcrossref))
suppressPackageStartupMessages(library(jsonlite))
suppressPackageStartupMessages(library(stringr))
suppressPackageStartupMessages(library(jsonlite))
suppressPackageStartupMessages(library(glue))
suppressPackageStartupMessages(library(janitor))
suppressPackageStartupMessages(library(httr))
``````{r}
get_names <- function(x) {
z <- cr_journals(x)$data
data.frame(issn = z$issn, publisher = z$publisher, title = z$title,
stringsAsFactors = FALSE)
}
``````{r get_facets, cache = TRUE}
url <- "https://api.crossref.org/works?filter=relation.type:has-preprint&facet=issn:*"
y <- httr::GET(url) %>% httr::content()
df <- (y$message$facets$issn$values) %>% bind_rows() %>% t() %>% data.frame()
df_clean <- df %>% rownames_to_column("issn")
names(df_clean) <- c("issn", "count")df_clean %>% mutate(issn2 = str_replace(issn, "http://id.crossref.org/issn/", "")) %>%
select(issn2, count) -> df2
names(df2) <- c("issn", "count")
``````{r get_issns, cache = TRUE, message = FALSE}
stuff <- list()
for (i in 1:nrow(df2)) {
x = df2[i, ]$issn
res <- get_names(x)
message("Retrieving issn ", i)
stuff[[i]] <- res
}stuff1 <- stuff[-(which(lengths(stuff) == 1))]
issn_lookup <- bind_rows(stuff1)
write_csv(issn_lookup, path = "issn_lookup.csv")
``````{r merge_issn_data, results= "as-is", cache = TRUE}
results <- left_join(df2, issn_lookup, by = "issn")
res <- results %>% filter(!is.na(publisher) & !is.na(title))
res %>% select(publisher, title, count) %>% distinct(publisher, count, title) -> clean_full_df
knitr::kable(clean_full_df)
``````{r}
write_csv(clean_full_df, path = "full_preprint_count.csv")
``````