This function is called by the provided Rd macro \\cite{pkg}{key}:

  • Parses the bibtex file references.bib in the root directory of package package using bibtex::read.bib().

  • Extracts the entry with key key.

  • Converts to Rd with tools::toRd().

cite_bib(package, key)

Arguments

package

(character(1))
Package to read the bibtex file from.

key

(character(1))
Entry of the bibtex file. If the key is "pkg::citation", the citation() information of the package is used instead.

Value

(character(1)) Bibentry formated as Rd.

Examples

# examplary bibtex file path = system.file("references.bib", package = "mlr3misc") cat(readLines(path), sep = "\n")
#> @article{mlr, #> author = {Bernd Bischl and Michel Lang and Lars Kotthoff and Julia Schiffner and Jakob Richter and Erich Studerus and Giuseppe Casalicchio and Zachary M. Jones}, #> title = {mlr: Machine Learning in R}, #> journal = {Journal of Machine Learning Research}, #> year = {2016}, #> volume = {17}, #> number = {170}, #> pages = {1-5}, #> url = {http://jmlr.org/papers/v17/15-066.html} #> }
# bibtex entry as raw Rd cite_bib("mlr3misc", "mlr")
#> [1] "mlr"
#> [1] "Bischl B, Lang M, Kotthoff L, Schiffner J, Richter J, Studerus E, Casalicchio G, Jones ZM (2016).\n\\dQuote{mlr: Machine Learning in R.}\n\\emph{Journal of Machine Learning Research}, \\bold{17}(170), 1-5.\n\\url{http://jmlr.org/papers/v17/15-066.html}.\n"
# citation info as raw Rd cite_bib("stats", "pkg::citation")
#> [1] "R Core Team (2017).\n\\emph{R: A Language and Environment for Statistical Computing}.\nR Foundation for Statistical Computing, Vienna, Austria.\n\\url{https://www.R-project.org/}."