Skip to content

Commit

Permalink
Merge pull request #26 from DataONEorg/develop
Browse files Browse the repository at this point in the history
Fix bug in issue 24 and add argument checking for issue 25
  • Loading branch information
jeanetteclark authored Apr 23, 2021
2 parents 9953752 + 07dfc52 commit 9a9ae0e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: scythe
Title: Harvest and register data package citations
Version: 0.9.0
Version: 0.9.1
Authors@R: c(
person("Jeanette", "Clark", role = c("aut", "cre"), email = "jeanetteclark@nceas.ucsb.edu", comment=c(ORCID = "0000-0003-4703-1974")),
person("Matthew B.", "Jones", role = "aut", email = "jones@nceas.ucsb.edu", comment=c(ORCID = "0000-0003-0077-4738")),
Expand Down
4 changes: 4 additions & 0 deletions R/citation_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
citation_search <- function(identifiers,
sources = c("plos", "scopus", "springer")) {

if(!("character" %in% class(identifiers))){
stop("Identifiers must be a character vector.")
}

# run the 'citation_search_*' function for each source
for (source in sources) {
search_function <- paste0(source, " <- citation_search_", source, "(identifiers)")
Expand Down
1 change: 1 addition & 0 deletions R/citation_search_plos.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ citation_search_plos <- function(identifiers) {
plos_results <- do.call(rbind, plos_results)
names(plos_results)[which(names(plos_results) == "id")] <- "article_id"
names(plos_results)[which(names(plos_results) == "title")] <- "article_title"
plos_results <- plos_results[complete.cases(plos_results), ]

return(plos_results)
}
5 changes: 3 additions & 2 deletions R/citation_search_scopus.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' }
citation_search_scopus <- function(identifiers) {

check_identifiers(identifiers)
identifiers <- check_identifiers(identifiers)

if (length(identifiers) > 8){
message(paste0("Your result will take ~", length(identifiers)/9 ," seconds to return, since this function is rate limited to 9 calls per second."))
Expand All @@ -25,7 +25,8 @@ citation_search_scopus <- function(identifiers) {
warning("Skipping Scopus search due to missing API key. Set an API key using scythe_set_key() to include Scopus results.")
return()
}
identifiers_enc <- utils::URLencode(identifiers, reserved = TRUE)
identifiers_enc <- lapply(identifiers, utils::URLencode, reserved = TRUE)
identifiers_enc <- unlist(identifiers_enc)
results <- list()
for (i in 1:length(identifiers_enc)) {
Sys.sleep(0.12)
Expand Down
6 changes: 5 additions & 1 deletion R/citation_search_springer.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ citation_search_springer <- function(identifiers) {
return()
}

identifiers_enc <- utils::URLencode(identifiers, reserved = T)
identifiers_enc <- lapply(identifiers, utils::URLencode, reserved = TRUE)
identifiers_enc <- unlist(identifiers_enc)

results <- list()
for (i in 1:length(identifiers_enc)) {
Expand Down Expand Up @@ -69,6 +70,9 @@ citation_search_springer <- function(identifiers) {

# remove doi: prefix for consistency
springer_results$article_id <- gsub("doi:", "", springer_results$article_id)

# drop NA results
springer_results <- springer_results[complete.cases(springer_results), ]

return(springer_results)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ including Scopus, PLOS, and Springer.
### Released version

```
remotes::install_github("DataONEorg/scythe@v0.9.0")
remotes::install_github("DataONEorg/scythe@v0.9.1")
```

The *scythe* R package should be available for use at this point.
Expand Down

0 comments on commit 9a9ae0e

Please sign in to comment.