knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Implementing journal abbreviation for the 'Journal' field in BibTex file.
# CRAN install.packages("journalabbr") # or devtools::install_github("zoushucai/journalabbr")
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 =
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/
shinyapps.io
, and the implementation is also very simple. Simply click the mouse in Rstudio
to operate itabbrtable = journalabbr:::abbrtable_sys colnames(abbrtable)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.