knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

journalabbr

CRAN status r-universe downloads CRAN RStudio mirror downloads R build status Codecov test coverage Lifecycle: stable

Function

Implementing journal abbreviation for the 'Journal' field in BibTex file.

Install

# CRAN
install.packages("journalabbr")

# or 
devtools::install_github("zoushucai/journalabbr")

Require

The format of the bib file is as follows:

@***{****,
  **** = {****},
  **** = "*****",
  *** = {{******}},
  **** = {*****}}

% or

@***{****,
  **** = {****},
  **** = "*****",
  *** = {{******}},
  **** = {*****}
  }

Except for the @character line, the rest of the field lines must have an equal sign =

Use

require(journalabbr)
# 1. load abbrtable_user
csvpath <- system.file("extdata", "myabbr.csv", package = "journalabbr", mustWork = TRUE)
abbrtable_user <- data.table::fread(file = csvpath, header = TRUE, sep = ",")
abbrtable_user <- abbrtable_user[, lapply(.SD, stringr::str_squish)]
colnames(abbrtable_user) <- c("journal_lower", "journal_abbr")
abbrtable_user[, journal_lower := tolower(journal_lower)]

# 2.read *.bib file
file <- system.file("extdata", "testfile_2.bib", package = "journalabbr", mustWork = TRUE)
dt <- read_bib2dt(file)

# 3. handle dt
dm1 = replace_field(dt,
                    oldfield = "JOURNAL",
                    newfield = "JOURNAL",
                    user_table = abbrtable_user,
                    use_sys_table =TRUE,
                    fun = NULL)
myauthor = function(x){ gsub(" and ", " & ", x, perl = TRUE, ignore.case = TRUE) }
dm2 = replace_field(dm1,
                    oldfield = "AUTHOR",
                    newfield = "AUTHOR",
                    user_table = NULL,
                    use_sys_table =FALSE,
                    fun = myauthor)
# 4. Write to .bib file:
write_dt2bib(dm2, file = tempfile(fileext = ".bib"))

print(head(dt)[, c("JOURNAL", "AUTHOR"), with = FALSE])
print(head(dm1)[, c("JOURNAL", "AUTHOR"), with = FALSE])
print(head(dm2)[, c("JOURNAL", "AUTHOR"), with = FALSE])

or run shiny

journalabbr::run_example()

or run shiny online

website: https://zoushucai.shinyapps.io/shiny_cankaowenxian/

Access internal data

abbrtable = journalabbr:::abbrtable_sys
colnames(abbrtable)


zoushucai/journalabbr documentation built on Dec. 6, 2024, 4:41 p.m.