R/utils.R

Defines functions parse_bib get_year make_key

make_key <- function(x) {
  #paste0(tolower(x$author[[1]]), get_year(x, 'created')[1])
  paste0(tolower(x$author[[1]]), x$year)
}

get_year <- function(x, field) {
  se(x[[field]], "[0-9]{4}")
}

parse_bib <- function(x) {
  x <- gsub("@[Dd]ata", "@Misc", x)
  tt <- tempfile(fileext = ".bib")
  writeLines(x, tt)
  output <- bibtex::read.bib(tt)
  unlink(tt)
  output
}
ropenscilabs/scitations documentation built on May 18, 2022, 8:31 p.m.