Created
November 25, 2016 12:10
-
-
Save tts/b3a707495df854339945d4a95ef38f12 to your computer and use it in GitHub Desktop.
Some metadata and URL of full-text OA articles by source type returned by oadoi.org
This file contains 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
library(purrr) | |
library(tidyr) | |
library(dplyr) | |
library(jsonlite) | |
# Data queried via oadoi.org API with the roadoi package. Title from local CRIS, joined with DOI. | |
# See https://users.aalto.fi/~sonkkila/oadoi.html | |
data <- read.csv(file = "repo_and_oadoi.csv", stringsAsFactors = F) | |
oa <- data[!is.na(data$free_fulltext_url), c("title", "evidence", "free_fulltext_url")] | |
names(oa) <- c("title", "evidence", "url") | |
# Convert to flare.json format for a D3 collapsible indented tree | |
# See https://gist.github.com/mbostock/1093025 | |
oa <- oa %>% | |
mutate(name = paste0(substr(title,1,100))) %>% | |
arrange(name) %>% | |
select(-title) | |
# http://stackoverflow.com/q/39228502 | |
nest_data <- oa %>% | |
group_by(evidence) %>% | |
nest(.key = children) %>% | |
rename(name = evidence) | |
nest_data_2 <- nest_data %>% | |
mutate(children = map(children, ~.x %>% | |
group_by(name,url))) | |
nest_data_3 <- data.frame(name="Free fulltext", children=I(list(nest_data_2))) | |
json <- toJSON(nest_data_3, pretty = T) | |
json <- gsub("^\\[", "", json) | |
json <- gsub("\\]$","", json) | |
sink("oa.json") | |
cat(json) | |
sink() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment