Last active
September 26, 2016 20:47
-
-
Save low-decarie/6b2cd953721954b81453cc0362fb1536 to your computer and use it in GitHub Desktop.
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
#Creates a histogram of publications per year from text currently in the clipboard. Must be edited for mac or windows. | |
require(stringr) | |
require(ggplot2) | |
#on windows | |
#text <- readLines("clipboard") | |
#for a mac | |
text <- readLines(textConnection(system("pbpaste",intern=TRUE))) | |
years <- as.numeric(na.omit(unlist(str_extract_all(text,"(19|20)[0-9][0-9]")))) | |
years <- years[years<2020] | |
years <- years[years>1950] | |
year_table <- data.frame(table(years)) | |
p <- ggplot(data=year_table, | |
aes(x=as.numeric(as.character(years)), | |
y=Freq))+ | |
geom_bar(stat="identity")+ | |
xlab("Years")+ | |
ylab("Number of articles") | |
print(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment