Skip to contents

This function adds a package to a BibTeX file. It uses the knitr::write_bib function to write the package name to the file.

Usage

add_pkg_to_bib(pkg_name, bib_file = "packages.bib")

Arguments

pkg_name

The name of the package to add to the BibTeX file.

bib_file

The name of the BibTeX file to write to.

Examples

my_bib_file <- tempfile(fileext = ".bib")
add_pkg_to_bib("dplyr", my_bib_file)
readLines(my_bib_file) |> cat(sep = "\n")
#> @Manual{R-base,
#>   title = {R: A Language and Environment for Statistical Computing},
#>   author = {{R Core Team}},
#>   organization = {R Foundation for Statistical Computing},
#>   address = {Vienna, Austria},
#>   year = {2024},
#>   url = {https://www.R-project.org/},
#> }
#> 
#> @Manual{R-dplyr,
#>   title = {dplyr: A Grammar of Data Manipulation},
#>   author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller and Davis Vaughan},
#>   year = {2023},
#>   note = {R package version 1.1.4},
#>   url = {https://dplyr.tidyverse.org},
#> }
#> 
#> @Manual{R-qtkit,
#>   title = {qtkit: Quantitative Text Kit},
#>   author = {Jerid Francom},
#>   year = {2024},
#>   note = {R package version 1.0.0},
#>   url = {https://cran.r-project.org/package=qtkit},
#> }
#>