Created
March 11, 2016 11:25
-
-
Save d0choa/af179797616c2d227620 to your computer and use it in GitHub Desktop.
This R script displays the number of manuscripts in each journal stored in the Mekentosj's Papers database during the last n years
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
## getJournalsFreq.R | |
## author: David Ochoa <dogcaesar@gmail.com> | |
## The script displays the number of manuscripts in each journal stored in the Mekentosj's Papers database | |
topN <- 20 #Top journals to display | |
lastyears <- 5 #Last n years | |
journalsquery <- "osascript -ss -e 'tell application \"Papers\" to get bundle name of publication items'" | |
yearsquery <- "osascript -e 'tell application \"Papers\" to get publication year of publication items'" | |
journals <- paste(system(journalsquery, intern=TRUE),collapse="") | |
journals <- gsub("\\{","",journals) | |
journals <- gsub("\\}","",journals) | |
journals <- unlist(strsplit(journals,"\", \"")) | |
journals <- gsub("\\\"","",journals) | |
years <- unlist(strsplit(paste(system(yearsquery, intern=TRUE),collapse=""), ", ")) | |
years[years == "missing value"] <- NA | |
df <- data.frame(journals=journals,years=as.numeric(years)) | |
thisyear <- as.numeric(unlist(strsplit(as.character(Sys.time()),"-"))[1]) | |
bundle_freq <- table(as.character(df[df$year > (thisyear - lastyears),"journals"])) | |
# Plotting | |
topJournals <- tail(sort(bundle_freq), n=topN) | |
colors <- colorRampPalette(c("#DEEBF7", "#084594")) | |
pdf(file="journalFreq.pdf") | |
par(las=2, | |
mar=c(5,12,4,2)) | |
barplot(topJournals, | |
main=paste("# of Manuscripts in my Papers Library (last",lastyears,"years)"), | |
horiz=TRUE, | |
border=FALSE, | |
xlab="Manuscripts", | |
col=colors(topN)) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
This R script displays the number of manuscripts in each journal stored in the Mekentosj's Papers database during the last n years. It does not require any additional files.
Requirements
Usage