Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding roxygen documentation

  • Loading branch information...
commit 4cfc1cf4d7568db378287ee135250fab300ef860 1 parent 6ed15d8
@sckott sckott authored
View
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
39 DESCRIPTION
@@ -1,10 +1,39 @@
Package: rplos
Description: A programmatic interface to the
- Web Service methods provided by the Public Library
- of Science journals.
+ Web Service methods provided by the Public Library
+ of Science journals.
Title: Interface to PLoS Journals API methods
Version: 0.0-1
License: BSD
-Author: Scott Chamberlain, Carl Boettiger
-Maintainer: Scott Chamberlain <myrmecocystus@gmail.com>
-Imports: RJSONIO, RCurl (>= 1.6), stringr, ggplot2, data.table
+Author: Scott Chamberlain, Carl Boettiger
+Maintainer: Scott Chamberlain <myrmecocystus@gmail.com>
+Imports:
+ RJSONIO,
+ RCurl (>= 1.6),
+ stringr,
+ ggplot2,
+ data.table
+Collate:
+ 'almplosallviews.R'
+ 'almplosallviewsdf.R'
+ 'almplotallviews.R'
+ 'almpub.R'
+ 'almpubmedcentid.R'
+ 'almpubmedid.R'
+ 'almtitle.R'
+ 'almtotcites.R'
+ 'almupdated.R'
+ 'articlelength.R'
+ 'browsepaper.R'
+ 'crossref.R'
+ 'formatarticleurl.R'
+ 'otherstuff.R'
+ 'plosabstract.R'
+ 'plosauthor.R'
+ 'plosfigtabcaps.R'
+ 'plossubject.R'
+ 'plostitle.R'
+ 'plosviews.R'
+ 'plosword.R'
+ 'plot_throughtime.R'
+ 'searchplos.R'
View
9 NAMESPACE
@@ -1,8 +1 @@
-import(RCurl)
-import(stringr)
-import(RJSONIO)
-import(ggplot2)
-import(data.table)
-import(googleVis)
-
-export(formatarticleurl, searchplos, plosauthor, plosword, plosabstract, plossubject, plostitle, crossref, plot_throughtime, articlelength)
+export(almplosallviews)
View
44 R/almplosallviews.R
@@ -1,24 +1,25 @@
-# plosallviews.R
-
-plosallviews <-
-# Function htmlviews to summarise all pdf, html, and xml views
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# source_ (character): Five categories of sources
-# Usage stats: counter [PLoS' own stats], pmc [PubMed].
-# Citations: pubmed, crossref, scopus, or wos [Web of Science].
-# Social: citeulike.
-# Blog entries: nature (no. of Nature blog articles that mentioned the article).
-# Inactive sources: researchblogging, connotea, bloglines, postgenomic
-# citations: include the individual citing document URIs, grouped by source,
-# TRUE (T) or FALSE (F) (character)
-# history: include a historical record of citation counts per month (cumulative),
-# grouped by source, TRUE (T) or FALSE (F) (character)
-# downform: download format (json, xml or csv)
-# Examples:
-# plosallviews('10.1371/journal.pbio.0000012', 'counter', T, T, 'xml')
-# plosallviews('10.1371/journal.pbio.0000012', 'citeulike', T, T, 'json')
-# plosallviews('10.1371/journal.pone.0005723', 'counter', T, T, 'csv')
+#' almplosallviews.R Alt-metrics_allviews
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param source_ source, one of counter, mpc, pubmed, crossref, scopus, wos,
+#' citeulike, nature, researchblogging, connotea, bloglines, postgenomic
+#' @param citations include the individual citing document URIs, grouped by
+#' source (logical)
+#' @param history include a historical record of citation counts per month
+#' (cumulative), grouped by source (logical)
+#' @param downform download format (json, xml or csv)
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return altmetrics as xml, json, or csv
+#' @examples \dontrun{
+#' plosallviews('10.1371/journal.pbio.0000012', 'counter', T, T, 'xml')
+#' plosallviews('10.1371/journal.pbio.0000012', 'citeulike', T, T, 'json')
+#' plosallviews('10.1371/journal.pone.0005723', 'counter', T, T, 'csv')
+#' }
+#' @export
+almplosallviews <-
function(doi, source_ = NA, citations = FALSE, history = FALSE, downform = NA,
url = 'http://alm.plos.org/articles',
@@ -53,6 +54,5 @@ function(doi, source_ = NA, citations = FALSE, history = FALSE, downform = NA,
# citations2, history2, '&api_key=', key, sep='')
# outprod <- read.csv(urlcsv)
# }
-
return(outprod)
}
View
27 R/almplotallviews.R
@@ -1,17 +1,16 @@
-# plotallviews.R
-
-plotallviews <-
-# Args:
-# data: JSON output downloaded from PLoS (character)
-# type: plot views for html, pdf, xml, any combination of two (e.g., 'html,pdf'),
-# or all (character)
-# Examples
-# out <- plosallviews('10.1371/journal.pbio.0000012', 'counter', 'json')
-# plotallviews(out, 'all')
-# plotallviews(out, 'pdf')
-# plotallviews(out, 'html,pdf')
-# Input: for now, the JSON output from the plosallviews function
-# Output: ggplot line plot
+#' almplotallviews.R Alt-metrics_plot_allviews
+#' @param data JSON output downloaded from PLoS (character)
+#' @param type plot views for html, pdf, xml, any combination of two
+#' (e.g., 'html,pdf'), or all (character)
+#' @return ggplot line plot
+#' @examples \dontrun{
+#' out <- plosallviews('10.1371/journal.pbio.0000012', 'counter', 'json')
+#' plotallviews(out, 'all')
+#' plotallviews(out, 'pdf')
+#' plotallviews(out, 'html,pdf')
+#' }
+#' @export
+almplotallviews <-
function(data, type = NA) {
View
23 R/almpub.R
@@ -1,11 +1,16 @@
-# almpub.R
-
+#' almpub.R Alt-metrics date updated
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return date when article data was last updated
+#' @examples \dontrun{
+#' almpub('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almpub <-
-# Function retrieves date when article data was last updated
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almpub('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +20,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$published
-
- return(outprod)
+ fromJSON(I(tt))$article$published
}
View
22 R/almpubmedcentid.R
@@ -1,11 +1,17 @@
-# almpubmedcentid.R
+#' almpubmedcentid.R Alt-metrics PubMed Central article ID
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return retrieves the PubMed Central article ID
+#' @examples \dontrun{
+#' almpubmedcentid('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almpubmedcentid <-
-# Function retrieves the PubMed Central article ID
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almpubmedcentid('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +21,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$pub_med_central
-
- return(outprod)
+ fromJSON(I(tt))$article$pub_med_central
}
View
23 R/almpubmedid.R
@@ -1,11 +1,16 @@
-# almpubmedid.R
-
+#' almpubmedid.R Alt-metrics PubMed article ID
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return retrieves the PubMed article ID
+#' @examples \dontrun{
+#' almpubmedid('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almpubmedid <-
-# Function retrieves the PubMed article ID
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almpubmedid('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +20,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$pub_med
-
- return(outprod)
+ fromJSON(I(tt))$article$pub_med
}
View
23 R/almtitle.R
@@ -1,11 +1,16 @@
-# almtitle.R
-
+#' almtitle.R Alt-metrics title of article
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return title of article
+#' @examples \dontrun{
+#' almtitle('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almtitle <-
-# Function retrieves the PubMed Central article ID
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almtitle('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +20,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$title
-
- return(outprod)
+ fromJSON(I(tt))$article$title
}
View
23 R/almtotcites.R
@@ -1,11 +1,16 @@
-# almtotcites.R
-
+#' almtotcites.R Alt-metrics total citation points from all sources
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return total no. data points recorded for this article from all sources
+#' @examples \dontrun{
+#' almtotcites('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almtotcites <-
-# Function retrieves the PubMed Central article ID
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almtotcites('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +20,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$citations_count
-
- return(outprod)
+ fromJSON(I(tt))$article$citations_count
}
View
23 R/almupdated.R
@@ -1,11 +1,16 @@
-# almupdated.R
-
+#' almupdated.R Alt-metrics date when article data was last updated
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return date when article data was last updated
+#' @examples \dontrun{
+#' almupdated('10.1371/journal.pbio.0000012')
+#' }
+#' @export
almupdated <-
-# Function retrieves date when article data was last updated
-# Args:
-# doi: digital object identifier for an article in PLoS Journals (string)
-# Examples:
-# almupdated('10.1371/journal.pbio.0000012')
function(doi,
url = 'http://alm.plos.org/articles',
@@ -15,7 +20,5 @@ function(doi,
url2 <- paste(url, "/", doi, '.json?api_key=', key, sep='')
tt <- getURLContent(url2)
- outprod <- fromJSON(I(tt))$article$updated_at
-
- return(outprod)
+ fromJSON(I(tt))$article$updated_at
}
View
34 R/articlelength.R
@@ -1,18 +1,24 @@
-# Retrieve article length
-
+#' articlelength.R Get article length
+#' @param id article identifier DOI = id, or subject area, e.g.: 'ecology'
+#' @param fields fields to return from search (character) [e.g., 'id,title'],
+#' any combination of search fields [see plosfields$field]
+#' @param limit number of results to return (integer)
+#' @param searchin search field to search in (character)
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return length of articles (no. words)
+#' @examples \dontrun{
+#' articlelength("10.1371/journal.pone.0004045", "body")
+#' articlelength("10.1371/journal.pone.0004045", "everything")
+#' articlelength("10.1371/journal.pone.0004045", "title")
+#' articlelength("ecology", "materials_and_methods", 500, "subject")
+#' articlelength("ecology", "results_and_discussion", 500, "subject")
+#' }
+#' @export
articlelength <-
-# Args:
-# id: article identifier DOI = id, or subject area, e.g.: 'ecology' (character)
-# fields: fields to return from search (character) [e.g., 'id,title'],
-# any combination of search fields [see plosfields$field]
-# limit: number of results to return (integer)
-# searchin: search field to search in (character)
-# Examples:
-# articlelength("10.1371/journal.pone.0004045", "body")
-# articlelength("10.1371/journal.pone.0004045", "everything")
-# articlelength("10.1371/journal.pone.0004045", "title")
-# articlelength("ecology", "materials_and_methods", 500, "subject")
-# articlelength("ecology", "results_and_discussion", 500, "subject")
function(id = NA, fields = NA, limit = NA, searchin = NA,
url = 'http://api.plos.org/search',
View
35 R/crossref.R
@@ -1,17 +1,22 @@
-# crossref.R
-# Author: Carl Boettiger <cboettig@gmail.com>
-#
-
-require(XML)
-require(RCurl)
-
+#' crossref.R lookup article info via CrossRef with DOI
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param url the PLoS API url for the function (should be left to default)
+#' @param key your PLoS API key, either enter, or loads from .Rprofile
+#' @param ... optional additional curl options (debugging tools mostly)
+#' @param curl If using in a loop, call getCurlHandle() first and pass
+#' the returned value in here (avoids unnecessary footprint)
+#' @return metadata from DOI
+#' @examples \dontrun{
+#' crossref("10.3998/3336451.0009.101")
+#' }
+#' @export
crossref <-
-# Returns metadata from DOI
-# Examples:
-# crossref("10.3998/3336451.0009.101")
-function(doi, url = "http://www.crossref.org/openurl/",
- key = getOption("CrossRefKey", stop("need an API key for Mendeley")), ...,
- curl = getCurlHandle())
+
+function(doi,
+ url = "http://www.crossref.org/openurl/",
+ key = getOption("CrossRefKey", stop("need an API key for Mendeley")),
+ ...,
+ curl = getCurlHandle())
{
## Assemble a url query such as:
#http://www.crossref.org/openurl/?id=doi:10.3998/3336451.0009.101&noredirect=true&pid=API_KEY&format=unixref
@@ -24,6 +29,4 @@ function(doi, url = "http://www.crossref.org/openurl/",
## should really return the content of other nodes too, but this is the important one.
nodeset = getNodeSet(ans, "//journal_article")
lapply(nodeset, xmlToList)
-}
-
-
+}
View
19 R/formatarticleurl.R
@@ -1,14 +1,15 @@
-# function to format a URL for a specific article in a specific journal
-
+#' formatarticleurl.R format a URL for a specific article in a specific journal
+#' @param doi digital object identifier for an article in PLoS Journals
+#' @param journal quoted journal name (character)
+#' @return get url for the article to use in your browser, etc
+#' @examples \dontrun{
+#' formatarticleurl("10.1371/journal.pone.0004045", 'PLoSONE')
+#' }
+#' @export
formatarticleurl <-
-# Args:
-# doi: doi for article (numeric)
-# journal: quoted journal name (character)
-# Output: URL
-# Examples:
-# myurl <- formatarticleurl(doi, 'PLoSBiology')
+
function(doi, journal)
{
paste(journalUrls[journal], '/article/info%3Adoi%2F',
str_replace(doi, '/', '%2F'), sep="")
-}
+}
View
21 R/otherstuff.R → data/journalUrls.R
@@ -1,15 +1,6 @@
-##### PLoS API queries code
-# require(RCurl)
-# require(stringr)
-# require(RJSONIO)
-
-# read in data frame describing search fields, read in as package data
-plosfields <- data(plosfields)
-# data(plosfields) # for when loading as package
-
-
+# journalUrls.R
# string with all journal base url's
-journalUrls <- c( # journal specific URL's for later use in code
+journalUrls <- c(
PLoSBiology = 'http://www.plosbiology.org',
PLoSGenetics = 'http://www.plosgenetics.org',
PLoSComputationalBiology = 'http://www.ploscompbiol.org',
@@ -17,10 +8,4 @@ journalUrls <- c( # journal specific URL's for later use in code
PLoSONE = 'http://www.plosone.org',
PLoSNeglectedTropicalDiseases = 'http://www.plosntds.org',
PLoSPathogens = 'http://www.plospathogens.org'
-)
-
-
-# Look at possible search fields for plos journals
-# plosfields$field
-
-
+)
View
54 man/almplosallviews.Rd
@@ -0,0 +1,54 @@
+\name{almplosallviews}
+\alias{almplosallviews}
+\title{almplosallviews.R Alt-metrics_allviews}
+\usage{
+ almplosallviews(doi, source_ = NA, citations = FALSE,
+ history = FALSE, downform = NA,
+ url = "http://alm.plos.org/articles",
+ key = getOption("PlosApiKey", stop("need an API key for PLoS Journals")),
+ ..., curl = getCurlHandle())
+}
+\arguments{
+ \item{doi}{digital object identifier for an article in
+ PLoS Journals}
+
+ \item{source_}{source, one of counter, mpc, pubmed,
+ crossref, scopus, wos, citeulike, nature,
+ researchblogging, connotea, bloglines, postgenomic}
+
+ \item{citations}{include the individual citing document
+ URIs, grouped by source (logical)}
+
+ \item{history}{include a historical record of citation
+ counts per month (cumulative), grouped by source
+ (logical)}
+
+ \item{downform}{download format (json, xml or csv)}
+
+ \item{key}{your PLoS API key, either enter, or loads from
+ .Rprofile}
+
+ \item{url}{the PLoS API url for the function (should be
+ left to default)}
+
+ \item{...}{optional additional curl options (debugging
+ tools mostly)}
+
+ \item{curl}{If using in a loop, call getCurlHandle()
+ first and pass the returned value in here (avoids
+ unnecessary footprint)}
+}
+\value{
+ altmetrics as xml, json, or csv
+}
+\description{
+ almplosallviews.R Alt-metrics_allviews
+}
+\examples{
+\dontrun{
+ plosallviews('10.1371/journal.pbio.0000012', 'counter', T, T, 'xml')
+ plosallviews('10.1371/journal.pbio.0000012', 'citeulike', T, T, 'json')
+ plosallviews('10.1371/journal.pone.0005723', 'counter', T, T, 'csv')
+}
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.