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)



Package to read the bibtex file from.


Entry of the bibtex file. If the key is "pkg::citation", the citation() information of the package is used instead. If the package provides multiple citation entries, a specific one can be selected by appending "::n" to the string key where n is the number of the citation entry (defaults to the first entry).


(character(1)) Bibentry formated as Rd.


# 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 = {} #> }
# bibtex entry as raw Rd cite_bib("mlr3misc", "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{}.\n"
# citation info as raw Rd cite_bib("stats", "pkg::citation")
#> [1] "R Core Team (2019).\n\\emph{R: A Language and Environment for Statistical Computing}.\nR Foundation for Statistical Computing, Vienna, Austria.\n\\url{}."