Type: Package
Title: Journal Abbreviations for BibTeX Documents
Version: 0.4.3
Description: Since the reference management software (such as 'Zotero', 'Mendeley') exports Bib file journal abbreviation is not detailed enough, the 'journalabbr' package only abbreviates the journal field of Bib file, and then outputs a new Bib file for generating reference format with journal abbreviation on other software (such as 'texstudio'). The abbreviation table is from 'JabRef'. At the same time, 'Shiny' application is provided to generate 'thebibliography', a reference format that can be directly used for latex paper writing based on 'Rmd' files.
License: GPL (≥ 3)
URL: https://github.com/zoushucai/journalabbr
BugReports: https://github.com/zoushucai/journalabbr/issues
Encoding: UTF-8
Depends: R (≥ 4.3.0)
Imports: data.table (≥ 1.14.0), stringr (≥ 1.4.0), purrr (≥ 1.0.0), httr (≥ 1.4.0), shiny (≥ 1.7.0), tidytable (≥ 0.11.0), stringi (≥ 1.7.0)
Suggests: testthat (≥ 3.0.0), rmarkdown, knitr, rclipboard, tinytex, DT, covr
RoxygenNote: 7.3.1
Config/testthat/edition: 3
Date: 2024-02-21
NeedsCompilation: no
Packaged: 2024-02-21 13:59:59 UTC; ubuntu
Author: ShuCai Zou [aut, cre], Yu Chen [aut]
Maintainer: ShuCai Zou <zscmoyujian@163.com>
Repository: CRAN
Date/Publication: 2024-02-21 14:20:02 UTC

journalabbr: Journal Abbreviations for BibTeX Documents

Description

Since the reference management software (such as 'Zotero', 'Mendeley') exports Bib file journal abbreviation is not detailed enough, the 'journalabbr' package only abbreviates the journal field of Bib file, and then outputs a new Bib file for generating reference format with journal abbreviation on other software (such as 'texstudio'). The abbreviation table is from 'JabRef'. At the same time, 'Shiny' application is provided to generate 'thebibliography', a reference format that can be directly used for latex paper writing based on 'Rmd' files.

Author(s)

Maintainer: ShuCai Zou zscmoyujian@163.com

Authors:

See Also

Useful links:


Journal field abbreviation of BibTeX file.

Description

Input Bib file with complete journal, output a .bib file and return a data object.

Input Bib file with complete journal, output a .bib file, this function only carries out journal abbreviations, and the rest is output as it is.

Usage

abbr_bib(
  file,
  out.file = tempfile(fileext = ".bib"),
  author.connect = c("nothing", "\\\\&", "&", "and"),
  user.csv = "",
  ...
)

abbr_bib_only_journal(
  file,
  out.file = tempfile(fileext = ".bib"),
  user.csv = "",
  ...
)

Arguments

file

character, file path to write the .bib file.

out.file

character, file path to write the .bib file.

author.connect

character, what symbols are used to connect multiple authors, 'nothing','\\&', '&', 'and', where 'nothing' stand for do nothing(default).

user.csv

character, csv file path, Users can customize the path of journal abbreviation. The csv file requires semicolon to segment data without header. The first column is the full name of the journal and the second column is the journal abbreviation.

...

(generalized), Parameters from data.table::fread.

Value

output a new Bib file and return a data.table object.

Examples

require(journalabbr)
path <- system.file("extdata", "testfile_2.bib", package = "journalabbr", mustWork = TRUE)
temptab <- abbr_bib(file = path, out.file = tempfile(fileext = ".bib"))

# add user csv
csvpath <- system.file("extdata", "myabbr.csv", package = "journalabbr", mustWork = TRUE)
temptab1 <- abbr_bib(file = path, out.file = tempfile(fileext = ".bib"), user.csv = csvpath)

# no return value
abbr_bib_only_journal(file = path, out.file = tempfile(fileext = ".bib"), user.csv = csvpath)


Add user's journal abbreviation table

Description

Add user's journal abbreviation table

Usage

add_abbrtable(file, ...)

Arguments

file

character, bib file path

...

see also data.table::fread

Value

a data.table

Examples

csvpath <- system.file("extdata", "myabbr.csv", package = "journalabbr", mustWork = TRUE)
abbrtable_user <- add_abbrtable(file = csvpath, header = FALSE, sep = ",")
colnames(abbrtable_user)


Parse a BibTeX file to a data.table.

Description

The BibTeX file is read, parsed, tidied and written to a data.table.

Usage

read_bib2dt(file)

Arguments

file

character, path or URL to a bib file.

Details

Read, parse and collate bibtex file to form a data.table. Different BIB may produce different data.table columns.

Value

A data.table.

Author(s)

ShuCai Zou

Examples

# Read from .bib file:
file1 <- system.file("extdata", "testfile_1.bib", package = "journalabbr", mustWork = TRUE)
dt1 <- read_bib2dt(file1)
colnames(dt1)

file2 <- system.file("extdata", "testfile_2.bib", package = "journalabbr", mustWork = TRUE)
dt2 <- read_bib2dt(file2)
colnames(dt2)


Replace field journal with built-in data sets and user provided data sets.

Description

Replace field journal with built-in data sets and user provided data sets.

Replace field author

Usage

replace_field_journal(dt, abbrtable_user)

replace_field_author(
  dt,
  author.connect = c("nothing", "\\\\&", "&", "and")
)

Arguments

dt

is data.table, the object returned by the function read_bib2dt.

abbrtable_user

data.table, the object returned by the function add_abbrtable.

author.connect

is character, what symbols are used to connect multiple authors, 'nothing','\\&', '&', 'and', where 'nothing' stand for do nothing(default).

Value

data.table

data.table

Examples

csvpath <- system.file("extdata", "myabbr.csv", package = "journalabbr", mustWork = TRUE)
abbrtable_user <- add_abbrtable(file = csvpath, header = FALSE, sep = ",")
colnames(abbrtable_user)

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

newdt <- replace_field_journal(dt, abbrtable_user)
newdt1 <- replace_field_author(dt, author.connect = "and")
newdt2 <- replace_field_author(dt, author.connect = "&")


The Shiny Program for the 'journalabbr' Package

Description

The Shiny Program for the 'journalabbr' Package

Usage

run_example()

Export a BibTeX data.table to a .bib file.

Description

The BibTeX data.table is written to a .bib file.

Usage

write_dt2bib(dt, file = tempfile(fileext = ".bib"))

Arguments

dt

data.table, in the format as returned by read_bib2dt.

file

character, file path to write the .bib file.

Value

file as a character string, invisibly.

Examples

# Read from .bib file:
require(journalabbr)
file <- system.file("extdata", "testfile_2.bib", package = "journalabbr", mustWork = TRUE)
bib <- read_bib2dt(file)

# Write to .bib file:
write_dt2bib(bib, file = tempfile(fileext = ".bib"))