Skip to content

Commit 16acd73

Browse files
committed
fix some egs
1 parent 84a45eb commit 16acd73

File tree

5 files changed

+56
-43
lines changed

5 files changed

+56
-43
lines changed

R/cr_abstract.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#' cr_abstract(doi = '10.1109/TASC.2010.2088091')
99
#'
1010
#' # doi not found
11-
#' cr_abstract(doi = '10.5284/1011335')
11+
#' # cr_abstract(doi = '10.5284/1011335')
1212
#'
1313
#' # abstract not found, throws warning
14-
#' cr_abstract(doi = '10.1126/science.169.3946.635')
15-
#' cr_abstract(doi = '10.1371/journal.pone.0033693')
16-
#' cr_abstract(doi = '10.1007/12080.1874-1746')
14+
#' # cr_abstract(doi = '10.1126/science.169.3946.635')
15+
#' # cr_abstract(doi = '10.1371/journal.pone.0033693')
16+
#' # cr_abstract(doi = '10.1007/12080.1874-1746')
1717
#'
18-
#' cr_abstract(cr_r(1))
18+
#' # cr_abstract(cr_r(1))
1919
#' }
2020
cr_abstract<-function(doi, ...) {
2121
url<- paste0('http://api.crossref.org/works/', doi, '.xml')

R/cr_ft_text.R

+26-15
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,30 @@
7373
#' ### you can see available licenses with cr_licenses() function
7474
#' out <-
7575
#' cr_works(filter = list(has_full_text = TRUE,
76-
#' license_url="http://creativecommons.org/licenses/by/3.0/"))
77-
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
78-
#' cr_ft_text(links, 'xml')
76+
#' license_url="http://creativecommons.org/licenses/by/3.0/"),
77+
#' limit = 100)
78+
#' (links <- cr_ft_links(out$data$DOI[40], "all"))
79+
#' # cr_ft_text(links, 'xml')
7980
#'
8081
#' ## You can use cr_ft_xml, cr_ft_plain, and cr_ft_pdf to go directly to
8182
#' ## that format
8283
#' licenseurl <- "http://creativecommons.org/licenses/by/3.0/"
8384
#' out <- cr_works(
84-
#' filter = list(has_full_text = TRUE, license_url = licenseurl))
85-
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
85+
#' filter = list(has_full_text = TRUE, license_url = licenseurl),
86+
#' limit = 100)
87+
#' (links <- cr_ft_links(out$data$DOI[50], "all"))
8688
#' cr_ft_xml(links)
87-
#' cr_ft_pdf(links)
89+
#' #cr_ft_pdf(links)
8890
#'
89-
#' # Caching, for PDFs
90-
#' out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE)
91-
#' (links <- cr_ft_links(out$data$DOI[10], "all"))
92-
#' cr_ft_text(links, type = "pdf", cache=FALSE)
93-
#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
94-
#' # second time should be faster
95-
#' system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
96-
#' system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) )
97-
#' identical(cacheyes, cacheno)
91+
#' ### Caching, for PDFs
92+
#' # out <- cr_members(2258, filter=c(has_full_text = TRUE), works = TRUE)
93+
#' # (links <- cr_ft_links(out$data$DOI[10], "all"))
94+
#' # cr_ft_text(links, type = "pdf", cache=FALSE)
95+
#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
96+
#' ### second time should be faster
97+
#' # system.time( cacheyes <- cr_ft_text(links, type = "pdf", cache=TRUE) )
98+
#' # system.time( cacheno <- cr_ft_text(links, type = "pdf", cache=FALSE) )
99+
#' # identical(cacheyes, cacheno)
98100
#'
99101
#' ## elsevier
100102
#' ## requires extra authentication
@@ -178,20 +180,29 @@ get_url <- function(a, b){
178180
#' @rdname cr_ft_text
179181
cr_ft_plain<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
180182
verbose=TRUE, ...) {
183+
if (is.null(url$plain[[1]])) {
184+
stop("no plain text link found", call.=FALSE)
185+
}
181186
getTEXT(url$plain[[1]], "plain", cr_auth(url, 'plain'), ...)
182187
}
183188

184189
#' @export
185190
#' @rdname cr_ft_text
186191
cr_ft_xml<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
187192
verbose=TRUE, ...) {
193+
if (is.null(url$xml[[1]])) {
194+
stop("no xml link found", call.=FALSE)
195+
}
188196
getTEXT(url$xml[[1]], "xml", cr_auth(url, 'xml'), ...)
189197
}
190198

191199
#' @export
192200
#' @rdname cr_ft_text
193201
cr_ft_pdf<-function(url, path="~/.crossref", overwrite=TRUE, read=TRUE,
194202
cache=FALSE, verbose=TRUE, ...) {
203+
if (is.null(url$pdf[[1]])) {
204+
stop("no pdf link found", call.=FALSE)
205+
}
195206
getPDF(url$pdf[[1]], path, cr_auth(url, 'pdf'), overwrite, "pdf",
196207
read, verbose, cache, ...)
197208
}

cran-comments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ found no problems related to this new version.
2121

2222
-------
2323

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

2727
Thanks!
2828
Scott Chamberlain

man/cr_abstract.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/cr_ft_text.Rd

+18-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
close