Skip to content

Commit

Permalink
fix some egs
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Aug 25, 2016
1 parent 84a45eb commit 16acd73
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 43 deletions.
10 changes: 5 additions & 5 deletions R/cr_abstract.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#' cr_abstract(doi = '10.1109/TASC.2010.2088091')
#'
#' # doi not found
#' cr_abstract(doi = '10.5284/1011335')
#' # cr_abstract(doi = '10.5284/1011335')
#'
#' # abstract not found, throws warning
#' cr_abstract(doi = '10.1126/science.169.3946.635')
#' cr_abstract(doi = '10.1371/journal.pone.0033693')
#' cr_abstract(doi = '10.1007/12080.1874-1746')
#' # cr_abstract(doi = '10.1126/science.169.3946.635')
#' # cr_abstract(doi = '10.1371/journal.pone.0033693')
#' # cr_abstract(doi = '10.1007/12080.1874-1746')
#'
#' cr_abstract(cr_r(1))
#' # cr_abstract(cr_r(1))
#' }
cr_abstract <- function(doi, ...) {
url <- paste0('http://api.crossref.org/works/', doi, '.xml')
Expand Down
41 changes: 26 additions & 15 deletions R/cr_ft_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,30 @@
#' ### you can see available licenses with cr_licenses() function
#' out <-
#' cr_works(filter = list(has_full_text = TRUE,
#' license_url="http://creativecommons.org/licenses/by/3.0/"))
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
#' cr_ft_text(links, 'xml')
#' license_url="http://creativecommons.org/licenses/by/3.0/"),
#' limit = 100)
#' (links <- cr_ft_links(out$data$DOI[40], "all"))
#' # cr_ft_text(links, 'xml')
#'
#' ## You can use cr_ft_xml, cr_ft_plain, and cr_ft_pdf to go directly to
#' ## that format
#' licenseurl <- "http://creativecommons.org/licenses/by/3.0/"
#' out <- cr_works(
#' filter = list(has_full_text = TRUE, license_url = licenseurl))
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
#' filter = list(has_full_text = TRUE, license_url = licenseurl),
#' limit = 100)
#' (links <- cr_ft_links(out$data$DOI[50], "all"))
#' cr_ft_xml(links)
#' cr_ft_pdf(links)
#' #cr_ft_pdf(links)
#'
#' # Caching, for PDFs
#' out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE)
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
#' cr_ft_text(links, type = "pdf", cache=FALSE)
#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
#' # second time should be faster
#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
#' system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) )
#' identical(cacheyes, cacheno)
#' ### Caching, for PDFs
#' # out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE)
#' # (links <- cr_ft_links(out$data$DOI[10], "all"))
#' # cr_ft_text(links, type = "pdf", cache=FALSE)
#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
#' ### second time should be faster
#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
#' # system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) )
#' # identical(cacheyes, cacheno)
#'
#' ## elsevier
#' ## requires extra authentication
Expand Down Expand Up @@ -178,20 +180,29 @@ get_url <- function(a, b){
#' @rdname cr_ft_text
cr_ft_plain <- function(url, path = "~/.crossref", overwrite = TRUE, read=TRUE,
verbose=TRUE, ...) {
if (is.null(url$plain[[1]])) {
stop("no plain text link found", call. = FALSE)
}
getTEXT(url$plain[[1]], "plain", cr_auth(url, 'plain'), ...)
}

#' @export
#' @rdname cr_ft_text
cr_ft_xml <- function(url, path = "~/.crossref", overwrite = TRUE, read=TRUE,
verbose=TRUE, ...) {
if (is.null(url$xml[[1]])) {
stop("no xml link found", call. = FALSE)
}
getTEXT(url$xml[[1]], "xml", cr_auth(url, 'xml'), ...)
}

#' @export
#' @rdname cr_ft_text
cr_ft_pdf <- function(url, path = "~/.crossref", overwrite = TRUE, read=TRUE,
cache=FALSE, verbose=TRUE, ...) {
if (is.null(url$pdf[[1]])) {
stop("no pdf link found", call. = FALSE)
}
getPDF(url$pdf[[1]], path, cr_auth(url, 'pdf'), overwrite, "pdf",
read, verbose, cache, ...)
}
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ found no problems related to this new version.

-------

This submission includes a few minor changes: improve documentation
and use new function for one of the package imports.
This submission includes a new function, an RStudio Addin, and
a number of bug fixes.

Thanks!
Scott Chamberlain
10 changes: 5 additions & 5 deletions man/cr_abstract.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions man/cr_ft_text.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 16acd73

Please sign in to comment.