Skip to content

Commit

Permalink
add optional arg to write_citation_pairs to pass to bib2df
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanetteclark committed Aug 26, 2024
1 parent 0661ef5 commit 1a44a8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions R/write_citation_pairs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#'
#' @param citation_list (data.frame) data.frame of citation pairs containing variables article_id and dataset_id
#' @param path (char) path to write JSON citation pairs to
#' @param extra_fields (char) list of extra fields to pass to bib2df::bib2df
#' @import dplyr
#' @export
#'
Expand All @@ -12,7 +13,7 @@
#' write_citation_pairs(citation_list = pairs, path = "citation_pairs.json")
#' }

write_citation_pairs <- function(citation_list, path) {
write_citation_pairs <- function(citation_list, path, extra_fields = NULL) {

if (!requireNamespace("bib2df", quietly = TRUE)) {
stop("The 'bib2df' package is required for this function but is not installed. Please install it.", call. = FALSE)
Expand Down Expand Up @@ -43,7 +44,7 @@ write_citation_pairs <- function(citation_list, path) {
writeLines(bib_full, t)

# import as a dataframe
df <- bib2df::bib2df(t)
df <- bib2df::bib2df(t, extra_fields = extra_fields)

# assign article_id to data.frame
df$dataset_id <- citation_list$dataset_id
Expand Down
4 changes: 3 additions & 1 deletion man/write_citation_pairs.Rd

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

0 comments on commit 1a44a8a

Please sign in to comment.