### Get example BibTeX file path Source: https://geobosh.github.io/rbibutils/index.html Locate the example BibTeX file with Latin-1 accents that is used in the readBib examples. Some characters may not display correctly on some locales, and on Windows some may be approximated. ```R bibacc <- system.file("bib/latin1accents_utf8.bib", package = "rbibutils") ``` -------------------------------- ### Get path to example BibTeX file cyr_utf8.bib Source: https://geobosh.github.io/rbibutils/reference/bibConvert.html Locate the path to the example BibTeX file 'cyr_utf8.bib' included in the rbibutils package. This file is used as input for conversion examples. ```r fn_cyr_utf8 <- system.file("bib", "cyr_utf8.bib", package = "rbibutils") ``` -------------------------------- ### Examples: register_JSSextra usage and default style changes Source: https://geobosh.github.io/rbibutils/reference/register_JSSextra.html Example R session showing how to check the current default style, register 'JSSextra', make it default, and change the default style using tools::bibstyle(). The output includes warnings and environment addresses. ```r ## current default style tools::getBibstyle() #> [1] "JSSextra" tools::getBibstyle(TRUE) # all styles, currently "JSS" only #> [1] "JSS" "JSSextra" "JSSextraLongNames" register_JSSextra() # register "JSSextra" #> Warning: No longer needed. to make JSSextra default, use tools::bibentry("JSSextra", .default = TRUE) #> tools::getBibstyle(TRUE) # now it is available #> [1] "JSS" "JSSextra" "JSSextraLongNames" tools::getBibstyle() # ... but not default #> [1] "JSSextra" register_JSSextra(TRUE) # this makes it default #> Warning: No longer needed. to make JSSextra default, use tools::bibentry("JSSextra", .default = TRUE) #> tools::getBibstyle() #> [1] "JSSextra" ## setting default style with bibstyle(): tools::bibstyle("JSS", .default = TRUE) #> tools::getBibstyle() #> [1] "JSS" ``` -------------------------------- ### Install rbibutils development version from GitHub Source: https://geobosh.github.io/rbibutils/index.html Install the development version of rbibutils from GitHub using devtools. ```R library(devtools) install_github("GeoBosh/rbibutils") ``` -------------------------------- ### Install rbibutils from CRAN Source: https://geobosh.github.io/rbibutils/index.html Install the latest stable version of rbibutils from CRAN. ```R install.packages("rbibutils") ``` -------------------------------- ### Convert bibentry to bibentryExtra with as.bibentryExtra() Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Creates a bibentry object with two entries (a manual and a book) and converts it to a bibentryExtra object using as.bibentryExtra(). The example is taken from the ?bibentry help page. ```R ## example bib from ?bibentry bref <- c( bibentry( bibtype = "Manual", title = "boot: Bootstrap R (S-PLUS) Functions", author = c( person("Angelo", "Canty", role = "aut", comment = "S original"), person(c("Brian", "D."), "Ripley", role = c("aut", "trl", "cre"), comment = "R port, author of parallel support", email = "ripley@stats.ox.ac.uk") ), year = "2012", note = "R package version 1.3-4", url = "https://CRAN.R-project.org/package=boot", key = "boot-package" ), bibentry( bibtype = "Book", title = "Bootstrap Methods and Their Applications", author = as.person("Anthony C. Davison [aut], David V. Hinkley [aut]"), year = "1997", publisher = "Cambridge University Press", address = "Cambridge", isbn = "0-521-57391-2", url = "http://statwww.epfl.ch/davison/BMA/", key = "boot-book" ) ) brefExtra <- as.bibentryExtra(bref) ``` -------------------------------- ### Read BibTeX with direct option Source: https://geobosh.github.io/rbibutils/index.html Import the example BibTeX file with the direct option, which is equivalent to specifying texChars = "keep". ```R be1 <- readBib(bibacc, direct = TRUE) ## readBib(bibacc, direct = TRUE, texChars = "keep") # same be1 print(be1, style = "bibtex") ``` -------------------------------- ### Read BibTeX with default TeX handling Source: https://geobosh.github.io/rbibutils/index.html Import the example BibTeX file into a bibentry object using the default behavior, which keeps TeX escape sequences as is. ```R be0 <- readBib(bibacc) be0 print(be0, style = "bibtex") ``` -------------------------------- ### Convert BibLaTeX to XML with bibConvert Source: https://geobosh.github.io/rbibutils/reference/bibConvert.html Example from the 'Examples' section showing how to convert a BibLaTeX file to XML using bibConvert. The first block sets up the input file path and displays it; the second block creates a temporary output file and calls bibConvert, with the returned list showing the input/output filenames and reference counts. ```r fn_biblatex <- system.file("bib", "ex0.biblatex", package = "rbibutils") fn_biblatex #> [1] "/home/runner/work/_temp/Library/rbibutils/bib/ex0.biblatex" ## file.show(fn_biblatex) ``` ```r ## convert a biblatex file to xml modl <- tempfile(fileext = ".xml") bibConvert(infile = fn_biblatex, outfile = modl, informat = "biblatex", outformat = "xml") #> $infile #> [1] "/home/runner/work/_temp/Library/rbibutils/bib/ex0.biblatex" #> #> $outfile #> [1] "/tmp/RtmpK0WFVt/file1ecd729430b6.xml" #> #> $nref_in #> [1] 3 #> #> $nref_out #> [1] 3 ``` -------------------------------- ### bibConvert Source: https://geobosh.github.io/rbibutils/reference/bibConvert.html Documentation for the bibConvert function, including usage, arguments, return value, and an example. ```APIDOC ## bibConvert ### Description Converts bibliography files between different formats. The function is used for the side effect of creating a file in the requested format. ### Usage ```r bibConvert(infile, outfile, informat, outformat) ``` ### Arguments - **infile** (character) - Required - Name of the input file. - **outfile** (character) - Required - Name of the output file. - **informat** (character) - Required - Input format (e.g., "biblatex"). - **outformat** (character) - Required - Output format (e.g., "xml"). ### Value Returns a list with components: - **infile** (character) - Name of the input file. - **outfile** (character) - Name of the output file. - **nref_in** (integer) - Number of references read from the input file. - **nref_out** (integer) - Number of references written to the output file. - **bib** (bibentry, optional) - A bibentry object obtained by reading `outfile` when `outformat` is one of `"R"`, `"r"`, or `"bibentry"`; otherwise not present. ### Details Normally, `nref_in` and `nref_out` are the same. If some references were imported successfully but failed on export, `nref_out` may be smaller than `nref_in`. In such cases informative messages are printed during processing. ### Examples ```r fn_biblatex <- system.file("bib", "ex0.biblatex", package = "rbibutils") modl <- tempfile(fileext = ".xml") bibConvert(infile = fn_biblatex, outfile = modl, informat = "biblatex", outformat = "xml") ``` ``` -------------------------------- ### Read large BibTeX file with readBib() and macros Source: https://geobosh.github.io/rbibutils/reference/readBib.html This commented example demonstrates reading a large BibTeX file with readBib() using macro files. It requires internet access or a local clone of the repository. It shows how to download the files, read the bibliography, and inspect entries. ```R ## a large example with several files - needs internet access; ## it is better to clone repository https://github.com/iridia-ulb/references ## and work on local files ## ## iridia_mac <- c("abbrev.bib", "authors.bib", "journals.bib", "crossref.bib") ## iridia_biblio <- "biblio.bib" ## ## iridia_raw_url <- "https://raw.githubusercontent.com/iridia-ulb/references/master" ## iridia_mac_url <- file.path(iridia_raw_url, iridia_mac) ## iridia_biblio_url <- file.path(iridia_raw_url, iridia_biblio) ## ## bibdir <- tempdir() ## iridia_mac_loc <- file.path(bibdir, iridia_mac) ## iridia_biblio_loc <- file.path(bibdir, iridia_biblio) ## ## ## download the files to bibdir ## sapply(c(iridia_biblio_url, iridia_mac_url), ## function(x) download.file(x, file.path(bibdir, basename(x)))) ## ## iridia <- readBib(iridia_biblio_loc, direct = TRUE, macros = iridia_mac_loc) ## iridia[1] ## print(iridia[1], style = "R") ## toBibtex(iridia[1]) # or: print(iridia[1], style = "bibtex") ## length(iridia) # 2576 at the time of writing ``` -------------------------------- ### Read BibTeX and export TeX characters Source: https://geobosh.github.io/rbibutils/index.html Import the example BibTeX file and export other characters to ASCII TeX sequences when possible. This option does not handle mathematical expressions well. ```R be3 <- readBib(bibacc, direct = TRUE, texChars = "export") print(be3, style = "bibtex") ``` -------------------------------- ### Convert UTF-8 BibTeX to gb18030 and RDS Source: https://geobosh.github.io/rbibutils/reference/bibConvert.html Prepares filenames for the gb18030 examples, then converts a UTF-8 BibTeX file to gb18030 and to an RDS file. The RDS conversion returns the parsed bibliography object, shown in the output. ```R xeCJK_utf8 <- system.file("bib/xeCJK_utf8.bib", package = "rbibutils") xeCJK_gb18030 <- system.file("bib/xeCJK_gb18030.bib", package = "rbibutils") fn_gb18030 <- tempfile(fileext = ".bib") fn_rds <- tempfile(fileext = ".rds") ``` ```R ## input bib file utf8, output bib file gb18030: bibConvert(xeCJK_utf8, fn_gb18030, encoding = c("utf8", "gb18030")) #> $infile #> [1] "/home/runner/work/_temp/Library/rbibutils/bib/xeCJK_utf8.bib" #> #> $outfile #> [1] "/tmp/RtmpK0WFVt/file1ecd18dd6dc2.bib" #> #> $nref_in #> [1] 1 #> #> $nref_out #> [1] 1 #> ``` ```R ## input bib file utf8, output file rds (and the rds object is returned bibConvert(xeCJK_utf8, fn_rds) #> $infile #> [1] "/home/runner/work/_temp/Library/rbibutils/bib/xeCJK_utf8.bib" #> #> $outfile #> [1] "/tmp/RtmpK0WFVt/file1ecd353d36a1.rds" #> #> $nref_in #> [1] 1 #> #> $nref_out #> [1] 1 #> #> $bib #> 陈骁, 黄声华, 万山明, 庞珽 (2012). #> “基于电无级变速器的内燃机最优控制策略及整车能量管理.” _电工技术学报_, #> *27*(2), 133-138. #> unlink(fn_gb18030) unlink(fn_rds) ``` -------------------------------- ### Set cite keys with charToBib() Source: https://geobosh.github.io/rbibutils/reference/readBib.html These examples show how to use charToBib() to assign cite keys to bibtex entries generated by citation(). The first sets a single key, the second sets two keys. The output confirms the keys are set correctly. ```R beRcore <- charToBib(toBibtex(citation()), key = "Rcore") beRcore$key == "Rcore" # TRUE #> [1] TRUE ``` ```R bemore <- charToBib(toBibtex( c(citation(), citation("rbibutils"))), key = c("Rcore", "Rpackage:rbibutils")) all.equal(names(bemore), c("Rcore", "Rpackage:rbibutils")) #> [1] TRUE ``` -------------------------------- ### Read BibTeX and convert TeX characters Source: https://geobosh.github.io/rbibutils/index.html Import the example BibTeX file and convert TeX sequences to true characters. On Windows, Greek characters alpha and delta may be printed as 'a' and 'd' but are internally correct. ```R be2 <- readBib(bibacc, direct = TRUE, texChars = "convert") be2 print(be2, style = "R") ``` -------------------------------- ### Create and print brefExtra copy Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Creates a copy of brefExtra and prints it to show the initial state before modifications. ```R b2 <- brefExtra b2 #> Canty A, Ripley BD (2012). _boot: Bootstrap R (S-PLUS) Functions_. R #> package version 1.3-4, . #> #> Davison AC, Hinkley DV (1997). _Bootstrap Methods and Their #> Applications_. Cambridge University Press, Cambridge. ISBN #> 0-521-57391-2, . ``` -------------------------------- ### writeBibentry(be, file = stdout(), style = c("Rstyle", "loose")) Source: https://geobosh.github.io/rbibutils/reference/readBibentry.html Writes a bibentry object to a file in the specified style. The default style is 'Rstyle', which wraps entries in c() and separates them with commas. The 'loose' style writes entries without separators and no wrapping. ```APIDOC ## writeBibentry(be, file = stdout(), style = c("Rstyle", "loose")) ### Description Writes a bibentry object to a file in the specified style. The default style is 'Rstyle', which wraps entries in c() and separates them with commas. The 'loose' style writes entries without separators and no wrapping. ### Usage writeBibentry(be, file = stdout(), style = c("Rstyle", "loose")) ### Arguments - **be** (bibentry object) - Required - The bibentry object to write. - **file** (character string or connection) - Optional - Filename or connection. Default is `stdout` (write to screen). - **style** (character) - Optional - One of `"Rstyle"` (default) or `"loose"`. `"Rstyle"` wraps in `c()` and puts commas between entries; `"loose"` does not wrap and does not put commas. ### Details Writes the object to the specified file in the requested style. The file is neatly formatted for humans to read and edit. ``` -------------------------------- ### Write bibentry objects to a .bib file with writeBibentry (Rstyle and loose) Source: https://geobosh.github.io/rbibutils/reference/readBibentry.html Reads a sample REFERENCES.bib file, writes it to a temporary .bib file using writeBibentry with the default style "Rstyle", prints the file contents, then writes again with style = "loose" and prints the result. The output shows the generated bibentry objects for both styles. The temporary file is removed with unlink(fn). ```R bibs <- readBib(system.file("REFERENCES.bib", package = "rbibutils"), encoding = "UTF-8") fn <- tempfile(fileext = ".bib") writeBibentry(bibs, file = fn) # style = "Rstyle" (default) cat(readLines(fn), sep = "\n") #> c( #> bibentry(bibtype = "Manual", #> key = "Rpackage:bibtex", #> author = person(given = "Romain", #> family = "Francois"), #> title = "bibtex: bibtex parser", #> year = "2014", #> note = "R package version 0.4.0"), #> #> bibentry(bibtype = "Misc", #> key = "Rpackage:Rdpack", #> author = person(given = c("Georgi", "N"), #> family = "Boshnakov"), #> title = "{Rdpack}: Update and Manipulate Rd Documentation Objects", #> year = "2020", #> note = "R package version 2.0.0", #> doi = "10.5281/zenodo.3925612", #> url = "https://doi.org/10.5281/zenodo.3925612"), #> #> bibentry(bibtype = "Article", #> key = "Rpackage:RefManageR", #> author = person(given = c("Mathew", "William"), #> family = "McLean"), #> title = "RefManageR: Import and Manage BibTeX and BibLaTeX References in R", #> journal = "The Journal of Open Source Software", #> year = "2017", #> doi = "10.21105/joss.00338", #> url = "https://doi.org/10.21105/joss.00338"), #> #> bibentry(bibtype = "Misc", #> key = "bibutils6.10", #> author = person(given = "Chris", #> family = "Putnam"), #> title = "Library bibutils, version 6.10", #> year = "2020", #> url = "https://sourceforge.net/projects/bibutils/"), #> #> bibentry(bibtype = "Misc", #> key = "Rpackage:easyPubMed", #> author = person(given = "Damiano", #> family = "Fantini"), #> title = "easyPubMed: Search and Retrieve Scientific Publication Records from PubMed", #> year = "2019", #> note = "R package version 2.13", #> url = "https://CRAN.R-project.org/package=easyPubMed") #> ) #> writeBibentry(bibs, file = fn, style = "loose") cat(readLines(fn), sep = "\n") #> bibentry(bibtype = "Manual", #> key = "Rpackage:bibtex", #> author = person(given = "Romain", #> family = "Francois"), #> title = "bibtex: bibtex parser", #> year = "2014", #> note = "R package version 0.4.0") #> #> bibentry(bibtype = "Misc", #> key = "Rpackage:Rdpack", #> author = person(given = c("Georgi", "N"), #> family = "Boshnakov"), #> title = "{Rdpack}: Update and Manipulate Rd Documentation Objects", #> year = "2020", #> note = "R package version 2.0.0", #> doi = "10.5281/zenodo.3925612", #> url = "https://doi.org/10.5281/zenodo.3925612") #> #> bibentry(bibtype = "Article", #> key = "Rpackage:RefManageR", #> author = person(given = c("Mathew", "William"), #> family = "McLean"), #> title = "RefManageR: Import and Manage BibTeX and BibLaTeX References in R", #> journal = "The Journal of Open Source Software", #> year = "2017", #> doi = "10.21105/joss.00338", #> url = "https://doi.org/10.21105/joss.00338") #> #> bibentry(bibtype = "Misc", #> key = "bibutils6.10", #> author = person(given = "Chris", #> family = "Putnam"), #> title = "Library bibutils, version 6.10", #> year = "2020", #> url = "https://sourceforge.net/projects/bibutils/") #> #> bibentry(bibtype = "Misc", #> key = "Rpackage:easyPubMed", #> author = person(given = "Damiano", #> family = "Fantini"), #> title = "easyPubMed: Search and Retrieve Scientific Publication Records from PubMed", #> year = "2019", #> note = "R package version 2.13", #> url = "https://CRAN.R-project.org/package=easyPubMed") unlink(fn) ``` -------------------------------- ### readBibentry(file, extra = FALSE, fbibentry = NULL) Source: https://geobosh.github.io/rbibutils/reference/readBibentry.html Reads a file containing bibentry calls and creates a bibentry object. The style is inferred from the file contents. Errors in bibentry calls are converted to warnings. ```APIDOC ## readBibentry(file, extra = FALSE, fbibentry = NULL) ### Description Reads a file containing bibentry calls and creates a bibentry object. The style is inferred from the file contents. Errors in bibentry calls are converted to warnings. ### Usage readBibentry(file, extra = FALSE, fbibentry = NULL) ### Arguments - **file** (character string or connection) - Required - Filename or connection. Input from console can be specified by `file = ""`. - **extra** (logical) - Optional - If `TRUE`, allow non-standard bibtex types. - **fbibentry** (function) - Optional - A function to use for generating bib objects. Default is `utils::bibentry()`. ### Details Reads the file and creates a `bibentry` object. The style is inferred from the contents of the file. `bibentry()` calls that throw errors are not included in the returned object; errors are intercepted and converted to warnings, identifying the corresponding `bibentry()` calls by their keys if present, otherwise the text of the whole bibentry is shown. ### Value A `bibentry` object. ``` -------------------------------- ### Read and write BibTeX files with readBib and writeBib Source: https://geobosh.github.io/rbibutils/reference/readBib.html Creates a bibentry object from a BibTeX file, writes it to a temporary file, and displays the file contents. The output shows the BibTeX entries for several R packages. ```R ## create a bibentry object bibs <- readBib(system.file("REFERENCES.bib", package = "rbibutils"), encoding = "UTF-8") ## write bibs to a file fn <- tempfile(fileext = ".bib") writeBib(bibs, fn) ## see the contents of the file readLines(fn) # or: file.show(fn) ``` ```output #> [1] "@Manual{Rpackage:bibtex," #> [2] " author = {Romain Francois}," #> [3] " title = {bibtex: bibtex parser}," #> [4] " year = {2014}," #> [5] " note = {R package version 0.4.0}," #> [6] "}" #> [7] "" #> [8] "@Misc{Rpackage:Rdpack," #> [9] " author = {Georgi N Boshnakov}," #> [10] " title = {{Rdpack}: Update and Manipulate Rd Documentation Objects}," #> [11] " year = {2020}," #> [12] " note = {R package version 2.0.0}," #> [13] " doi = {10.5281/zenodo.3925612}," #> [14] " url = {https://doi.org/10.5281/zenodo.3925612}," #> [15] "}" #> [16] "" #> [17] "@Article{Rpackage:RefManageR," #> [18] " author = {Mathew William McLean}," #> [19] " title = {RefManageR: Import and Manage BibTeX and BibLaTeX References in R}," #> [20] " journal = {The Journal of Open Source Software}," #> [21] " year = {2017}," #> [22] " doi = {10.21105/joss.00338}," #> [23] " url = {https://doi.org/10.21105/joss.00338}," #> [24] "}" #> [25] "" #> [26] "@Misc{bibutils6.10," #> [27] " author = {Chris Putnam}," #> [28] " title = {Library bibutils, version 6.10}," #> [29] " year = {2020}," #> [30] " url = {https://sourceforge.net/projects/bibutils/}," #> [31] "}" #> [32] "" #> [33] "@Misc{Rpackage:easyPubMed," #> [34] " author = {Damiano Fantini}," #> [35] " title = {easyPubMed: Search and Retrieve Scientific Publication Records from PubMed}," #> [36] " year = {2019}," #> [37] " note = {R package version 2.13}," #> [38] " url = {https://CRAN.R-project.org/package=easyPubMed}," #> [39] "}" ``` -------------------------------- ### Create and print a bibentry value Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Creates a second bibentry in the list b2 and prints the list. The output shows the formatted citation for the second entry, including the note and URL. ```r b2[[2]] <- bibentry(bibtype = "Misc", title = "Dummy title", author = "A A Dummy", organization = "none") b2 ``` ```r #> Canty A, Ripley BD (????). _New title A_. a new note, #> . #> #> Dummy AA (????). “Dummy title.” ``` -------------------------------- ### Assign title and note with wildcard Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Uses the wildcard '*' to assign both title and note fields to the first entry. ```R b2[[list(1, "*")]] <- list(title = "New title", note = "a new note") ``` -------------------------------- ### Convert biblatex to bibtex with bibConvert Source: https://geobosh.github.io/rbibutils/reference/bibConvert.html Creates temp files and calls bibConvert with informat = 'biblatex' and outformat = 'bib'. The output shows the return list with infile, outfile, nref_in, and nref_out values. ```R bib <- tempfile(fileext = ".bib") bib2 <- tempfile(fileext = ".bib") bibConvert(infile = fn_biblatex, outfile = bib, informat = "biblatex", outformat = "bib") #> $infile #> [1] "/home/runner/work/_temp/Library/rbibutils/bib/ex0.biblatex" #> #> $outfile #> [1] "/tmp/RtmpK0WFVt/file1ecd3d45dc2a.bib" #> #> $nref_in #> [1] 3 #> #> $nref_out #> [1] 3 #> ``` -------------------------------- ### brefExtra[["boot-book"]] with and without trailing comma Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Extracts the full entry for 'boot-book' using a trailing comma to return a list with attributes, and without the comma to return a formatted citation string. ```R brefExtra[["boot-book", ]] ``` ```R #> $title #> [1] "Bootstrap Methods and Their Applications" #> #> $author #> [1] "Anthony C. Davison [aut]" "David V. Hinkley [aut]" #> #> $year #> [1] "1997" #> #> $publisher #> [1] "Cambridge University Press" #> #> $address #> [1] "Cambridge" #> #> $isbn #> [1] "0-521-57391-2" #> #> $url #> [1] "http://statwww.epfl.ch/davison/BMA/" #> #> attr(,"bibtype") #> [1] "Book" #> attr(,"key") #> [1] "boot-book" ``` ```R brefExtra[["boot-book"]] ``` ```R #> Davison AC, Hinkley DV (1997). _Bootstrap Methods and Their #> Applications_. Cambridge University Press, Cambridge. ISBN #> 0-521-57391-2, . ``` -------------------------------- ### Convert BibTeX string to bibentry with charToBib Source: https://geobosh.github.io/rbibutils/reference/readBib.html Creates a BibTeX reference for R using citation(), adds a citation key, converts it with charToBib(), and prints the resulting bibentryExtra object. ```R Rcore <- format(citation(), style = "bibtex") Rcore <- sub("@Manual{", "@Manual{Rcore", Rcore, fixed = TRUE) cat(Rcore, sep = "\n") #> @Manual{Rcore, #> title = {R: A Language and Environment for Statistical Computing}, #> author = {{R Core Team}}, #> organization = {R Foundation for Statistical Computing}, #> address = {Vienna, Austria}, #> year = {2025}, #> url = {https://www.R-project.org/}, #> } beRcore <- charToBib(Rcore) beRcore #> R Core Team (2025). _R: A Language and Environment for Statistical #> Computing_. . class(beRcore) #> [1] "bibentryExtra" "bibentry" print(beRcore, style = "R") #> bibentry(bibtype = "Manual", #> key = "Rcore", #> author = person(family = "R Core Team"), #> title = "R: A Language and Environment for Statistical Computing", #> year = "2025", #> publisher = "R Foundation for Statistical Computing", #> address = "Vienna, Austria", #> url = "https://www.R-project.org/") ``` -------------------------------- ### register_JSSextra Source: https://geobosh.github.io/rbibutils/reference/register_JSSextra.html Creates and registers the 'JSSextra' bibstyle for use in the current R session. It can optionally make it the default style and force recreation of the style with reset = TRUE. ```APIDOC ## register_JSSextra ### Description Creates and registers the bibstyle "JSSextra" for use in the current R session. It can be specified for functions that accept a bibstyle argument, such as printing objects of class "bibentry" and "bibentryExtra". In normal use, it is called once per session. ### Usage register_JSSextra(make_default = FALSE, reset = FALSE, parent_style = "JSS") ### Arguments - **make_default** (logical) - If `TRUE`, make `"JSSextra"` the default style. - **reset** (logical) - If `TRUE`, recreate the bibstyle `"JSSextra"`. - **parent_style** (character) - The style from which to derive `"JSSextra"`. Default is `"JSS"`. ### Details - The function registers the style and optionally sets it as the default style. - By default, `"JSSextra"` is derived from `"JSS"`. Use `parent_style` to base it on a different style. - Using `tools::bibstyle()` the default style can be changed at any time. - `register_JSSextra(TRUE)` makes and registers `"JSSextra"` as the default style. - `reset = TRUE` forces a fresh copy of `"JSSextra"` to be created. ### Value Returns the created style (an environment). The side effect of registering and optionally setting the default style is the main purpose. ### Examples ```r ## current default style tools::getBibstyle() #> [1] "JSSextra" tools::getBibstyle(TRUE) # all styles, currently "JSS" only #> [1] "JSS" "JSSextra" "JSSextraLongNames" register_JSSextra() # register "JSSextra" #> Warning: No longer needed. to make JSSextra default, use tools::bibentry("JSSextra", .default = TRUE) #> tools::getBibstyle(TRUE) # now it is available #> [1] "JSS" "JSSextra" "JSSextraLongNames" tools::getBibstyle() # ... but not default #> [1] "JSSextra" register_JSSextra(TRUE) # this makes it default #> Warning: No longer needed. to make JSSextra default, use tools::bibentry("JSSextra", .default = TRUE) #> tools::getBibstyle() #> [1] "JSSextra" ## setting default style with bibstyle(): tools::bibstyle("JSS", .default = TRUE) #> tools::getBibstyle() #> [1] "JSS" ``` ``` -------------------------------- ### Usage of bibentryExtra and related methods Source: https://geobosh.github.io/rbibutils/reference/bibentryExtra.html Shows the function signatures and S3 method definitions for creating, converting, and manipulating 'bibentryExtra' objects. The arguments include bibtype, x, i, j, name, drop, and value. ```r bibentryExtra(bibtype = NULL, ...) as.bibentryExtra(x, ...) # S3 method for class 'bibentryExtra' x[[i, j, drop = TRUE]] # S3 method for class 'bibentryExtra' x[[i]] <- value # S3 method for class 'bibentryExtra' x[i, j, drop = TRUE] # S3 method for class 'bibentryExtra' x$name <- value ``` -------------------------------- ### Read BibTeX file with readBib and compare to input Source: https://geobosh.github.io/rbibutils/reference/readBib.html Reads the BibTeX file 'bibacc' using readBib with direct = TRUE, and optionally with texChars = 'keep'. The output is a bibentry object. The original file contents are shown for comparison. ```R readLines(bibacc) #> [1] " @ARTICLE{test1," #> [2] " AUTHOR = {Kàrè Lêáé}," #> [3] " TITLE = {Kàrè \\"u\\"a \\L\\lêáé}," #> [4] " JOURNAL = {Latin-1 accents}," #> [5] " YEAR = {2020}," #> [6] " NOTE = {Having the similar title and author is helpful for debugging since authors are" #> [7] " processed differently from other fields. Here is a formula: $\\tan(\\alpha)$," #> [8] " $\\sin(\\delta)/\\delta \\to 1$, $\\sqrt{x}$.}" #> [9] "}" ``` ```R be1 <- readBib(bibacc, direct = TRUE) be1a <- readBib(bibacc, direct = TRUE, texChars = "keep") # same be1 #> Lêáé K (2020). “Kàrè üä Łłêáé.” _Latin-1 accents_. Having the similar #> title and author is helpful for debugging since authors are processed #> differently from other fields. Here is a formula: $\tan(\alpha)$, #> $\sin(\delta)/\delta\to1$, $\sqrt{x}$. ``` ```R print(be1, style = "R") #> bibentry(bibtype = "Article", #> key = "test1", #> author = person(given = "Kàrè", #> family = "Lêáé"), #> title = "Kàrè \\"u\\"a \\L\\lêáé", #> journal = "Latin-1 accents", #> year = "2020", #> note = "Having the similar title and author is helpful for debugging since authors are processed differently from other fields. Here is a formula: $\\tan(\\alpha)$, $\\sin(\\delta)/\\delta \\to 1$, $\\sqrt{x}$.") ``` ```R print(be1, style = "bibtex") #> @Article{test1, #> author = {Kàrè Lêáé}, #> title = {Kàrè \"u\"a \L\lêáé}, #> journal = {Latin-1 accents}, #> year = {2020}, #> note = {Having the similar title and author is helpful for debugging since authors are processed differently from other fields. Here is a formula: $\tan(\alpha)$, $\sin(\delta)/\delta \to 1$, $\sqrt{x}$.}, #> } ``` -------------------------------- ### Display rbibutils_formats data frame Source: https://geobosh.github.io/rbibutils/reference/rbibutils_formats.html Display the built-in data frame rbibutils_formats, which lists the 16 supported bibliography formats with their abbreviations, file extensions, input/output support, and descriptions. The output shows the full table, including the Abbreviation, FileExt, Input, Output, and Description columns. ```r rbibutils_formats ``` ```r rbibutils_formats #> Abbreviation FileExt Input Output #> 1 ads ads FALSE TRUE #> 2 bib bib TRUE TRUE #> 3 bibtex bibtex TRUE TRUE #> 4 biblatex biblatex TRUE TRUE #> 5 copac copac TRUE FALSE #> 6 ebi ebi TRUE FALSE #> 7 end end TRUE TRUE #> 8 endx endx TRUE FALSE #> 9 isi isi TRUE TRUE #> 10 med med TRUE FALSE #> 11 nbib nbib TRUE TRUE #> 12 ris ris TRUE TRUE #> 13 R, r, Rstyle R TRUE TRUE #> 14 rds rds TRUE TRUE #> 15 xml xml TRUE TRUE #> 16 wordbib wordbib TRUE TRUE #> Description #> 1 ADS reference format #> 2 BibTeX #> 3 BibTeX #> 4 BibLaTeX #> 5 COPAC format references #> 6 EBI XML #> 7 EndNote (Refer format) #> 8 EndNote XML #> 9 ISI web of science #> 10 Pubmed XML references #> 11 Pubmed/National Library of Medicine nbib format #> 12 RIS format #> 13 R source file containing bibentry commands #> 14 bibentry object in a binary file created by saveRDS() #> 15 MODS XML intermediate #> 16 Word 2007 bibliography format ``` -------------------------------- ### Print bibentry in BibTeX style Source: https://geobosh.github.io/rbibutils/reference/readBib.html Prints the bibentry object 'be3' in BibTeX style. ```R print(be3, style = "bibtex") ``` -------------------------------- ### Read back converted files and convert them to other formats Source: https://geobosh.github.io/rbibutils/index.html Reads back the RDS and R files created by bibConvert and converts them back to BibTeX. ```R readLines("myfile.R") file.show("myfile.R") readRDS("myfile.rds") bibConvert("myfile.rds", "myfile.bib") bibConvert("myfile.R", "myfile.bib") ```