-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…funct now removed their test files as well also made all text mining fxns deprecated, to notify users of the new package and of future defunctifying #122 bumped patch version
- Loading branch information
Showing
29 changed files
with
298 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,11 @@ | ||
#' Search the CrossRef Metatdata API. | ||
#' | ||
#' | ||
#' @export | ||
#' | ||
#' @param query Query terms. | ||
#' @param doi Search by a single DOI or many DOIs. | ||
#' @param page Page to return from results. | ||
#' @param rows Number of records to return. | ||
#' @param sort Sort either by "score" or "year". | ||
#' @param year Year to search. | ||
#' @param type Record type, e.g., "Journal Article" or "Journal Issue" | ||
#' @param ... Named parameters passed on to \code{\link[httr]{GET}} | ||
#' | ||
#' @details See \url{http://search.labs.crossref.org/help/api} for more | ||
#' info on this Crossref API service. | ||
#' @seealso \code{\link{cr_r}}, \code{\link{cr_citation}}, | ||
#' \code{\link{cr_search_free}} | ||
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} | ||
#' @examples \dontrun{ | ||
#' cr_search(query = c("renear", "palmer")) | ||
#' | ||
#' # limit to 4 results | ||
#' cr_search(query = c("renear", "palmer"), rows = 4) | ||
#' | ||
#' # get more results than standard | ||
#' cr_search(query = c("renear", "palmer"), rows = 40) | ||
#' | ||
#' # sort results by score | ||
#' cr_search(query = c("renear", "palmer"), rows = 10, sort = "score") | ||
#' | ||
#' # sort results by year | ||
#' cr_search(query = c("renear", "palmer"), rows = 10, sort = "year") | ||
#' | ||
#' # get results for a certain year | ||
#' cr_search(query = c("renear", "palmer"), year = 2010) | ||
#' | ||
#' # search by a single DOI | ||
#' cr_search(doi = "10.1890/10-0340.1") | ||
#' | ||
#' # search for many DOI's | ||
#' # find all the records of articles from a journal ISBN | ||
#' cr_search(query = "1461-0248", type="Journal Article") | ||
#' | ||
#' # curl stuff | ||
#' library('httr') | ||
#' cr_search(doi = "10.1890/10-0340.1", config=verbose()) | ||
#' cr_search(query = c("renear", "palmer"), rows = 40, config=progress()) | ||
#' } | ||
|
||
`cr_search` <- function(query=NULL, doi=NULL, page=NULL, rows=NULL, sort=NULL, | ||
year=NULL, type=NULL, ...) { | ||
|
||
.Deprecated( | ||
package = "rcrossref", | ||
msg = "cr_search is deprecated, and will be removed in next version, see cr_works et al." | ||
#' @rdname cr_search-defunct | ||
#' @keywords internal | ||
`cr_search` <- function(...) { | ||
.Defunct( | ||
package = "rcrossref", | ||
msg = "Removed - see cr_works(), cr_journals(), etc. for similar functionality" | ||
) | ||
url <- "http://search.crossref.org/dois" | ||
if (!is.null(doi)) { | ||
doi <- as.character(doi) | ||
} | ||
if (is.null(doi)) { | ||
cr_search_GET(url, query, page, rows, sort, year, type, ...) | ||
} else { | ||
ldply(doi, function(z) cr_search_GET(url, x = z, page, rows, sort, | ||
year, type, ...)) | ||
} | ||
} | ||
|
||
cr_search_GET <- function(url, x, page, rows, sort, year, type, ...){ | ||
if (!is.null(x)) { | ||
if (length(x) > 1) x <- paste0(x, collapse = " ") | ||
} | ||
args <- cr_compact(list(q = x, page = page, rows = rows, | ||
sort = sort, year = year, type = type)) | ||
tt <- GET(url, query = args, make_rcrossref_ua(), ...) | ||
stop_for_status(tt) | ||
res <- ct_utf8(tt) | ||
tmp <- jsonlite::fromJSON(res) | ||
if (NROW(tmp) == 0) { | ||
NULL | ||
} else { | ||
col_classes( | ||
tmp, | ||
c("character","numeric","integer","character", | ||
"character","character","numeric") | ||
) | ||
} | ||
} | ||
|
||
asnum <- function(x){ | ||
tmp <- tryCatch(as.numeric(x), warning = function(w) w) | ||
if (inherits(tmp, "simpleWarning")) x else tmp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,11 @@ | ||
#' Search the CrossRef Metatdata for DOIs using free form references. | ||
#' | ||
#' @export | ||
#' | ||
#' @param query Reference query; a character vector of length 1 or greater, | ||
#' comma-separated of course. | ||
#' @param url Base url for the Crossref metadata API. | ||
#' | ||
#' @details Have to have at least three terms in each search query. | ||
#' @seealso \code{\link{cr_search}}, \code{\link{cr_r}}, | ||
#' \code{\link{cr_citation}} | ||
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com} | ||
#' @examples \dontrun{ | ||
#' # search with title, author, year, and journal | ||
#' cr_search_free(query = "Piwowar Sharing Detailed Research Data Is | ||
#' Associated with Increased Citation Rate PLOS one 2007") | ||
#' | ||
#' cr_search_free(query="Renear 2012") # too few words, need at least 3 | ||
#' | ||
#' # multiple queries | ||
#' cr_search_free(query=c("Renear 2012","Piwowar sharing data PLOS one")) | ||
#' | ||
#' # Get a DOI and get the citation using cr_search | ||
#' doi <- cr_search_free(query="Piwowar sharing data PLOS one")$doi | ||
#' cr_search(doi = doi) | ||
#' | ||
#' # Queries can be quite complex too | ||
#' cr_search_free("M. Henrion, D. J. Mortlock, D. J. Hand, and A. Gandy, | ||
#' \"A Bayesian approach to star-galaxy classification,\" Monthly Notices of | ||
#' the Royal Astronomical Society, vol. 412, no. 4, pp. 2286-2302, Apr. 2011.") | ||
#' | ||
#' # Lots of queries | ||
#' queries <- c( | ||
#' "Piwowar sharing data PLOS one", "Priem Scientometrics 2.0 social web", | ||
#' "William Gunn A Crosstalk Between Myeloma Cells", | ||
#' "karthik ram Metapopulation dynamics override local limits") | ||
#' cr_search_free(queries) | ||
#' } | ||
|
||
`cr_search_free` <- function(query, url = "http://search.crossref.org/links") { | ||
.Deprecated(package = "rcrossref", | ||
msg = "cr_search_free is deprecated, and will be removed in next version, see cr_works et al.") | ||
tt <- POST( | ||
url, | ||
config = c(content_type_json(), accept_json()), | ||
body = jsonlite::toJSON(query)) | ||
stop_for_status(tt) | ||
res <- ct_utf8(tt) | ||
fromJSON(res)$results | ||
#' @rdname cr_search_free-defunct | ||
#' @keywords internal | ||
`cr_search_free` <- function(...) { | ||
.Defunct( | ||
package = "rcrossref", | ||
msg = "Removed - see cr_works(), cr_journals(), etc. for similar functionality" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,11 @@ | ||
#' Crosscite - citation formatter | ||
#' | ||
#' @export | ||
#' @param dois Search by a single DOI or many DOIs. | ||
#' @param style a CSL style (for text format only). See | ||
#' \code{\link{get_styles}} for options. Default: apa. If there's a style that | ||
#' CrossRef doesn't support you'll get a \code{(500) Internal Server Error} | ||
#' @param locale Language locale. See \code{?Sys.getlocale} | ||
#' @template moreargs | ||
#' @details See \url{http://www.crosscite.org/cn/} for more info on the | ||
#' Crossref Content Negotiation API service. | ||
#' | ||
#' This function is now deprecated. It will be removed in the next version | ||
#' of this package. Use \code{\link{cr_cn}} instead. | ||
#' | ||
#' @examples \dontrun{ | ||
#' crosscite("10.5284/1011335") | ||
#' crosscite(c('10.5169/SEALS-52668','10.2314/GBV:493109919', | ||
#' '10.2314/GBV:493105263', '10.2314/GBV:487077911', | ||
#' '10.2314/GBV:607866403')) | ||
#' } | ||
|
||
`crosscite` <- function(dois, style = 'apa', locale = "en-US", | ||
.progress = "none", ...) { | ||
|
||
.Deprecated( | ||
new = "cr_cn", | ||
package = "rcrossref", | ||
msg = "crosscite is deprecated - will be removed in next version, use cr_cn" | ||
#' @rdname crosscite-defunct | ||
#' @keywords internal | ||
`crosscite` <- function(...) { | ||
.Defunct( | ||
package = "rcrossref", | ||
msg = "Removed - see cr_works(), cr_journals(), etc. for similar functionality" | ||
) | ||
if (length(dois) > 1) { | ||
llply(dois, function(z, ...) { | ||
out <- try(ccite(z, style, locale, ...), silent=TRUE) | ||
if ("try-error" %in% class(out)) { | ||
warning( | ||
paste0("Failure in resolving '", z, "'. See error detail in results.") | ||
) | ||
out <- list(doi=z, error=out[[1]]) | ||
} | ||
return(out) | ||
}, .progress=.progress) | ||
} else { | ||
ccite(dois, style, locale, ...) | ||
} | ||
} | ||
|
||
ccite <- function(doi, style, locale, ...) { | ||
args <- cr_compact(list(doi = doi, style = style, locale = locale)) | ||
res <- GET(ccurl(), query = args, make_rcrossref_ua(), ...) | ||
stop_for_status(res) | ||
gsub("\n", "", ct_utf8(res)) | ||
} | ||
|
||
ccurl <- function() "http://crosscite.org/citeproc/format" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.