R/helpers.R

Defines functions text_between_curly_brackets na_replace capitalize

capitalize <- function(string) {
  paste0(substr(string, 1, 1),
         tolower(substr(string, 2, nchar(string))))
}

na_replace <- function(df) {
  df[is.na(df)] <- ""
  return(df)
}

text_between_curly_brackets <- function(string) {
  min <- min(gregexpr("\\{", string)[[1]])
  max <- max(gregexpr("\\}", string)[[1]])
  content <- substring(string, min + 1, max - 1)
  return(content)
}
ottlngr/bib2df documentation built on April 9, 2024, 8:15 a.m.