library("tidyverse")
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
## ── Attaching packages ────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.1 ✔ purrr 0.3.2
## ✔ tibble 2.1.2 ✔ dplyr 0.8.1
## ✔ tidyr 0.8.3 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.4.0
## ── Conflicts ───────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library("rjson")
library("magicfor")
myDOI <- readr::read_csv(here::here("data/BalciSdoi.txt"), col_names = "DOI", col_types = "c")
myDOI <- myDOI %>%
mutate(
apitallies = paste0("https://api.scite.ai/tallies/", DOI)
) %>%
rownames_to_column()
magicfor::magic_for(silent = TRUE)
json_data <- for (i in 1:(dim(myDOI)[1]-1)) {
json_name <- paste0("Article", myDOI$rowname[i])
json_data <- rjson::fromJSON(file = myDOI$apitallies[i])
put(json_name, json_data)
}
jsonDF <- magicfor::magic_result_as_dataframe()
magicfor::magic_free()
jsonDF <- dplyr::bind_rows(jsonDF$json_data, .id = "meta_information")
df <- jsonDF %>%
filter(total > 0) %>%
select(doi,
contradicting,
mentioning,
supporting,
unclassified
) %>%
gather(key = feature, value = number, -doi)
library(ggplot2)
ggplot(data = df) +
aes(x = doi, fill = feature, color = feature, weight = number) +
geom_bar(position = 'fill') +
labs(x = 'DOI',
y = 'Percentage Of Article Citation Features') +
theme_minimal() +
coord_flip()
