yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
135 stars 28 forks source link

Feature request: Ignore empty packages in `session_info()` #65

Closed phargarten2 closed 2 years ago

phargarten2 commented 2 years ago

Thank you for the easy and aesthetically pleasing package of information via session_info().

In my work, I list the packages used in every R file and then combine them at the end. At times, an empty string appears in the character vector sent to argument package (package = ""). The function yields an error:

xfun::session_info(packages = c("", "xfun"))
Error in isNamespaceLoaded(pkg) : 
  attempt to use zero-length variable name

The error indicates that removing an empty string from package would give the result.

>  xfun::session_info(packages = c("xfun"))
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042), RStudio 2022.2.2.485

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:
  graphics_4.2.0  grDevices_4.2.0 stats_4.2.0     tools_4.2.0     utils_4.2.0     xfun_0.30  

What I would like is for the function to ignore "" and give the results of the non-empty strings (in this case xfun.) instead of preparing packages with no empty strings. The result would be the information above using the call xfun::session_info(packages = c("", "xfun"))


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.

[Given that this is a feature request for this function, I didn't ask on Stack Overflow.]

yihui commented 2 years ago

Done. Thanks for the suggestion!