knitr::opts_chunk$set(
  fig.width=6, 
    fig.height=5, 
    fig.pos="h",
    message=FALSE, 
    warning=FALSE, 
    comment="#>", 
    cache=TRUE
)

alm tutorial

The alm package is a set of functions to access article level metrics via a RESTful API from the Rails app Lagotto created by the Public Library of Science (PLOS). Lagotto is being used by PLOS, and a number of other publishers:

A good place to look for the status of various installations of Lagotto is this status page: http://articlemetrics.github.io/status/ (which also includes what version of Lagotto each is running)

Help with Lagotto

Lagotto has a nice support site at http://discuss.lagotto.io/ for any questions about it.

What is an article level metric?

Glad you asked. The canonical URL for this is perhaps altmetrics.org. Basically it is a metric that measures something about an article. This is in stark contrast to journal level metrics, like the Journal Impact Factor.

Are there other altmetrics data providers?

Yes indeedy, but see notes

Authentication

You only need an API key for the publishers PKP and Pensoft. You can set the key in your options just for the current session by executing options(PlosApiKey = "YOUalmAPIKEY"), or pass in to each function call with the key parameter, or save in your .Rprofile file.

URLs

The default URL is set for the PLOS data sources: http://alm.plos.org/api/v5/articles You can change this URL. For example, if you want to get data from the Crossref instance, set the api_url parameter to http://alm.labs.crossref.org/api/v5/articles

Other languages

If R is not your thing, there are Lagotto clients in development for Ruby and Python.

Help

If you are having trouble with this R package, contact the maintainer, Scott. If you are having trouble with the API itself, there is a newish discussion forum for the Lagotto service at http://discuss.lagotto.io/.

Install and load

Stable version from CRAN

install.packages("alm")

Or development version from GitHub

install.packages("devtools")
devtools::install_github("ropensci/alm")

Load alm

library("alm")

Get data

alm_ids(doi="10.1371/journal.pone.0029797")

Details for a single DOI

out <- alm_ids(doi='10.1371/journal.pone.0029797', info='detail')

info

out$data$info

sign posts

out$data$signposts

totals

out$data$totals

history

out$data$sum_metrics

Search using various identifiers, including pubmed id, pmc id, and mendeley id

A single PubMed ID (pmid)

alm_ids(pmid=22590526)

A single PubMed Central ID (pmcid)

alm_ids(pmcid=212692)

Search on many identifiers

dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117',
    '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395')
out <- alm_ids(doi=dois)
lapply(out$data, head)

Get altmetrics by year

You can also get metrics by day (sum_metrics='day') or month (sum_metrics='month')

alm_ids(doi='10.1371/journal.pone.0036240', sum_metrics='year')

Output an-easy-to-combine-with-other-results data.frame

alm_ids(doi='10.1371/journal.pone.0035869', total_details=TRUE)$data[,3:7]

Get detailed data for altmetrics using almevents

out <- alm_events(doi="10.1371/journal.pone.0029797")
names(out)

Get the results for PubMed Central

# remove those with no data
out <- out[!out %in% c("sorry, no events content yet","parser not written yet")]
out[["pmc"]]

Get the results for twitter

out$twitter$events[1:3,]

Retrieve and plot PLOS article-level metrics signposts.

dat <- alm_signposts(doi="10.1371/journal.pone.0029797")
plot_signposts(input=dat)

Or plot many identifiers gives a line chart

library("ggplot2")
dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117','10.1371/journal.pone.0029797','10.1371/journal.pone.0039395')
dat <- alm_signposts(doi=dois)
plot_signposts(input=dat) + 
  theme_grey(base_size = 12)

Or make an interactive chart by doing plot_signposts(input=dat, type="multiBarChart"). Try it out! It should open in your browser and you can interact with it.

Density and histogram plots from PLOS Article Level Metrics data

Note: Do you the key below in the searchplos call in this example, but if you plan to use rplos more, get your own API key here.

library('rplos')
library('plyr')
dois <- searchplos(q='science', fl="id", fq=list('cross_published_journal_key:PLoSONE', 'doc_type:full', 'publication_date:[2010-01-01T00:00:00Z TO 2010-12-31T23:59:59Z]'), limit=75)

Remove non-full article DOIs

dois <- dois$data$id
dois <- dois[!grepl("annotation", dois)]

Collect altmetrics data and combine to a data.frame with ldply

alm <- alm_ids(doi=dois, total_details=TRUE)
alm <- ldply(alm$data)

The default plot

plot_density(alm)

You can change the color of the density plot

plot_density(alm, color="#EFA5A5")

Pass in a title or description subtending the title

plot_density(alm, title="Scopus citations from 2010")

Plot a particular source

plot_density(alm, source="crossref_total")

Plot many sources in different panels in the same plot, and pass in colors just for fun

plot_density(input=alm, 
             source=c("counter_html","crossref_total","pubmed_total","scopus_total"),
             color=c("#83DFB4","#EFA5A5","#CFD470","#B2C9E4")) + 
  theme_grey(base_size = 12)

CrossRef article level metrics

Notice that we are passing the base url for the Crossref API, whereas the default is for the PLOS url http://alm.plos.org/api/v5/articles.

url <- "http://det.labs.crossref.org/api/v5/articles"
dois <- c("10.1371/journal.pone.0086859", "10.1038/nature12990", "10.5860/choice.51-3037")
alm_ids(doi=dois, api_url = url)


ropensci/alm documentation built on May 18, 2022, 9:47 a.m.