Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
fixed up alm_events for change in source param, closes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Oct 14, 2014
1 parent f923cd6 commit d3c7689
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 8 additions & 6 deletions R/alm_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' @param pmid PubMed object identifier (numeric)
#' @param pmcid PubMed Central object identifier (numeric)
#' @param mendeley_uuid Mendeley object identifier (character)
#' @param source The source to get events data from. You can pass in a character
#' vector, like: \code{c("mendeley","crossref")}
#' @param source (character) Name of source to get ALM information for. One source only.
#' You can get multiple sources via a for loop or lapply-type call.
#' @param key your PLoS API key, either enter, or loads from .Rprofile (character)
#' @param url API endpoint, defaults to http://alm.plos.org/api/v3/articles (character)
#' @param ... optional additional curl options (debugging tools mostly)
Expand Down Expand Up @@ -78,7 +78,9 @@
#' alm_events(doi="10.1371/journal.pone.0035869", source="crossref")
#'
#' # Specify two specific sources
#' alm_events(doi="10.1371/journal.pone.0035869", source=c("crossref","twitter"))
#' ## You have to do so through lapply, or similar approach
#' lapply(c("crossref","twitter"),
#' function(x) alm_events(doi="10.1371/journal.pone.0035869", source=x))
#'
#' # Figshare data
#' alm_events(doi="10.1371/journal.pone.0069841", source='figshare')
Expand All @@ -103,7 +105,7 @@
#' # F1000 Prime data
#' alm_events(doi="10.1371/journal.pbio.1001041", source='f1000')
#' dois <- c('10.1371/journal.pmed.0020124','10.1371/journal.pbio.1001041',
#' '10.1371/journal.pbio.0040020','10.1371/journal.pmed.1001300')
#' '10.1371/journal.pbio.0040020')
#' res <- alm_events(doi = dois, source='f1000')
#' res[[3]]
#' }
Expand Down Expand Up @@ -140,10 +142,10 @@ alm_events <- function(doi = NULL, pmid = NULL, pmcid = NULL, mendeley_uuid = NU
id <- almcompact(list(doi=doi, pmid=pmid, pmcid=pmcid, mendeley_uuid=mendeley_uuid))
if(length(id)>1) stop("Only supply one of: doi, pmid, pmcid, mendeley_uuid")
key <- getkey(key)
source2 <- if(is.null(source)) NULL else paste(source, collapse=",")
if(length(source) > 1) stop("You can only supply one source")

parse_events <- function() {
args <- almcompact(list(api_key = key, info = 'detail', source = source2, type = names(id)))
args <- almcompact(list(api_key = key, info = 'detail', source = source, type = names(id)))
if(length(id[[1]])==0){stop("Please provide a DOI")} else
if(length(id[[1]])==1){
if(names(id) == "doi") id <- gsub("/", "%2F", id)
Expand Down
10 changes: 6 additions & 4 deletions man/alm_events.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ alm_events(doi = NULL, pmid = NULL, pmcid = NULL, mendeley_uuid = NULL,

\item{mendeley_uuid}{Mendeley object identifier (character)}

\item{source}{The source to get events data from. You can pass in a character
vector, like: \code{c("mendeley","crossref")}}
\item{source}{(character) Name of source to get ALM information for. One source only.
You can get multiple sources via a for loop or lapply-type call.}

\item{key}{your PLoS API key, either enter, or loads from .Rprofile (character)}

Expand Down Expand Up @@ -95,7 +95,9 @@ out['19390606']
alm_events(doi="10.1371/journal.pone.0035869", source="crossref")

# Specify two specific sources
alm_events(doi="10.1371/journal.pone.0035869", source=c("crossref","twitter"))
## You have to do so through lapply, or similar approach
lapply(c("crossref","twitter"),
function(x) alm_events(doi="10.1371/journal.pone.0035869", source=x))

# Figshare data
alm_events(doi="10.1371/journal.pone.0069841", source='figshare')
Expand All @@ -120,7 +122,7 @@ headfoo(alm_events(doi="10.1371/journal.pmed.1001587", source='articlecoveragecu
# F1000 Prime data
alm_events(doi="10.1371/journal.pbio.1001041", source='f1000')
dois <- c('10.1371/journal.pmed.0020124','10.1371/journal.pbio.1001041',
'10.1371/journal.pbio.0040020','10.1371/journal.pmed.1001300')
'10.1371/journal.pbio.0040020')
res <- alm_events(doi = dois, source='f1000')
res[[3]]
}
Expand Down

0 comments on commit d3c7689

Please sign in to comment.