-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#' Get Crossref metadata from API | ||
#' | ||
#' @param dois character vector with DOIs | ||
#' @param .progress show progress bar, use "none" if no progress should be | ||
#' displayed | ||
#' | ||
#' @family ETL import | ||
#' @export | ||
get_cr_md <- function(dois, .progress = "text") { | ||
# TODO this can be replaced by class validation | ||
# TODO not sure where the best place for the unique assertion is | ||
checkmate::assert_character(dois, any.missing = FALSE, unique = TRUE) | ||
|
||
tt <- rcrossref::cr_works(dois = dois, .progress = .progress)[["data"]] | ||
if (!is.null(tt)) { | ||
out <- tt %>% | ||
mutate(issued = lubridate::parse_date_time(issued, c("y", "ymd", "ym"))) %>% | ||
mutate(issued_year = lubridate::year(issued)) | ||
} else { | ||
out <- NULL | ||
} | ||
out | ||
} |