Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write.bib chooses the wrong citation, and doesn't warn that there was an option #39

Open
SamBuckman opened this issue Jun 3, 2021 · 3 comments

Comments

@SamBuckman
Copy link

Some of the packages in R have multiple citations associated with them. For example knitr::write_bib("testthat") returns

@Manual{R-testthat,
title = {testthat: Unit Testing for R},
author = {Hadley Wickham},
year = {2021},
note = {R package version 3.0.2},
url = {https://CRAN.R-project.org/package=testthat},
}

@Article{testthat2011,
author = {Hadley Wickham},
title = {testthat: Get Started with Testing},
journal = {The R Journal},
year = {2011},
volume = {3},
pages = {5--10},
url = {https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf},
}

The first one is the citation for the package, so it's the one I want. But bibtex::write.bib("testthat") gives the second one, and doesn't warn that it's doing it.

@sckott
Copy link
Collaborator

sckott commented Jun 8, 2021

knitr::write_bib appears to get a citation for the package derived from the DESCRIPTION file + use any citations from an optional CITATION file

whereas write.bib here does not generate the @Manual citation since if there's a CITATION file in the package, then utils::citation only gets the citation in that file

@sckott
Copy link
Collaborator

sckott commented Jun 8, 2021

Wonder if bibtex should change to follow what knitr::write_bib does or not

@zeileis
Copy link

zeileis commented Oct 22, 2021

One option would be to give bibtex::write.bib() an additional argument ... and pass that to

bibs <- sapply(pkgs, function(x) try(citation(x, ...)), simplify = FALSE)

Then you can do

bibtex::write.bib("testthat", auto = TRUE)

which generates the "auto" citation from the DESCRIPTION file

@Manual{testthat,
  title = {testthat: Unit Testing for R},
  author = {Hadley Wickham},
  year = {2021},
  note = {R package version 3.0.4},
  url = {https://CRAN.R-project.org/package=testthat},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants