library(tidybibtex)
The package contains a sample BibTeX file called sample_bib.
Note that this object is a character vector. If you want to import your own BibTeX file, please use the readLines()
function. It’s a base R function, so you don’t need to install any new library.
sample_bib[1:10]
#> [1] "@article{nolan2010computing,"
#> [2] " title={Computing in the statistics curricula},"
#> [3] " author={Nolan, Deborah and Temple Lang, Duncan},"
#> [4] " journal={The American Statistician},"
#> [5] " volume={64},"
#> [6] " number={2},"
#> [7] " pages={97--107},"
#> [8] " year={2010},"
#> [9] " publisher={Taylor \\& Francis}"
#> [10] "}"
In case you want to capitalize the title field.
capitalize_field(vec = sample_bib[1:10],
field = "title")
#> [1] "@article{nolan2010computing,"
#> [2] " title={Computing In The Statistics Curricula},"
#> [3] " author={Nolan, Deborah and Temple Lang, Duncan},"
#> [4] " journal={The American Statistician},"
#> [5] " volume={64},"
#> [6] " number={2},"
#> [7] " pages={97--107},"
#> [8] " year={2010},"
#> [9] " publisher={Taylor \\& Francis}"
#> [10] "}"
In case you want to capitalize the title field except “in” and “the.”
capitalize_field(vec = sample_bib[1:10],
field = "title",
exceptions = c("in", "the"))
#> [1] "@article{nolan2010computing,"
#> [2] " title={Computing in the Statistics Curricula},"
#> [3] " author={Nolan, Deborah and Temple Lang, Duncan},"
#> [4] " journal={The American Statistician},"
#> [5] " volume={64},"
#> [6] " number={2},"
#> [7] " pages={97--107},"
#> [8] " year={2010},"
#> [9] " publisher={Taylor \\& Francis}"
#> [10] "}"
You can simply the above steps using the cap_bib_field()
function.
cap_bib_field(file_path = <Insert the file path>,
vec = sample_bib[1:10],
field = "title",
exceptions = c("in", "the"))