Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/karthik/preprint-count


https://github.com/karthik/preprint-count

Last synced: about 1 month ago
JSON representation

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")
```

```