yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.37k stars 874 forks source link

`knitr::write_bib()` gives error for empty string #2240

Closed phargarten2 closed 1 year ago

phargarten2 commented 1 year ago

I like to keep track of the libraries used in a character vector, and at times, an empty string gets added to the character vector of strings that are passed to write_bib().

x <- c("", "haven", "knitr")
knitr::write_bib(x)
# Error in isNamespaceLoaded(pkg) : 
# attempt to use zero-length variable name

Although I can remove it beforehand, I would like knitr::write_bib() to ignore any empty strings passed to it and create references based on the other packages.

Session Info

# xfun::session_info('knitr')

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044), RStudio 2022.12.0.353

Locale:
  LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
  LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

Package version:
  evaluate_0.20   graphics_4.2.2  grDevices_4.2.2 highr_0.10      knitr_1.42      methods_4.2.2   stats_4.2.2    
  tools_4.2.2     utils_4.2.2     xfun_0.37       yaml_2.3.7  

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 1 year ago

Thanks !

github-actions[bot] commented 10 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.