Skip to content

Instantly share code, notes, and snippets.

@sckott
Created November 6, 2012 19:40
Show Gist options
  • Save sckott/4026985 to your computer and use it in GitHub Desktop.
Save sckott/4026985 to your computer and use it in GitHub Desktop.
Get altmetrics data on PLoS papers in R.
## This gist is an example of getting altmetrics data on PLoS papers.
## In a nutshell, this script reads in a list of DOIs provided by Martin Fenner of PLoS, and gets the historical altmetrics
## data on each DOI, and writes it to a txt file. You can do lots of things with this data. How do different altmetrics
## relate to one another within a paper, across papers, how do they vary through time for a paper, etc.
## I ran this in an EC2 using an m2.2xlarge instance.
## It took about XX to run.
## The resulting file was about XXX mb.
library(devtools)
install_github('rplos', 'ropensci', 'almv3')
# install.packages(c("ggplot2","plyr"))
library(rplos); library(ggplot2); library(plyr); library(doMC); library(multicore); library(reshape2)
# setwd("/Users/ScottMac/Dropbox/alm12-sf-hackathon")
# dir()
dois <- read.csv("alm_report_2012-09-12.csv")[,1]
dff <- data.frame(.id = "NA", dates = "NA", totals = "NA", doi = "NA")
write.table(dff, "dfftable.txt", row.names=F)
getwrite <- function(x){
out <- almplosallviews(x, info='detail')$history
out$doi <- rep(x, nrow(out))
if(!is.null(out)){write.table(out, "dfftable.txt", append=T, col.names=F, row.names=F)} else {NULL}
}
registerDoMC(cores=8)
out <- llply(dois, getwrite, .parallel=T)
# started ~945 AM on 06-Nov-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment