Last active
March 24, 2019 16:32
-
-
Save jabranham/887495eaf029680316fecb374f0723e0 to your computer and use it in GitHub Desktop.
analyze-bib-file
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(tidyverse) | |
library(bibtex) | |
theme_set(theme_minimal()) | |
## You'll need to modify the next line to wherever your bib file is | |
entries <- read.bib("~/Dropbox/bibliography/references.bib") | |
lentries <- length(entries) | |
years <- list(lentries) | |
type <- list(lentries) | |
journals <- list(lentries) | |
for (i in 1:length(entries)) { | |
years[i] <- entries[[i]]$year | |
type[i] <- attributes(unclass(entries)[[i]])$bibtype | |
if (type[i] == "Article"){ | |
journals[i] <- entries[i]$journal | |
} else journals[i] <- NA | |
} | |
entries <- data.frame(year = as.numeric(unlist(years)), | |
type = unlist(type), | |
journal = unlist(journals)) | |
## Make a graph of year vs count, but exclude years before 1950 | |
entries %>% | |
filter(year > 1950) %>% | |
ggplot(aes(year)) + | |
geom_bar() + | |
labs(x = "Year", | |
y = "Count") | |
## Graph of type (article, book, etc) | |
entries %>% | |
ggplot(aes(type)) + | |
geom_bar() | |
## Graph of count per journal | |
entries %>% | |
group_by(journal) %>% | |
summarize(n = n()) %>% | |
arrange(desc(n)) %>% | |
mutate(journal = factor(journal, levels = .$journal[order(.$n)])) %>% | |
filter(n > 4, !is.na(journal)) %>% | |
ggplot(aes(journal, n)) + | |
geom_bar(stat = "identity") + | |
labs(x = "Journal", | |
y = "Count") + | |
theme(axis.text.x = element_text(angle = 45, hjust = 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great, it will be nicer to show a table version of the data