Created
March 9, 2017 12:02
-
-
Save jonocarroll/a5f8b302f8c310346ad1a8b590781378 to your computer and use it in GitHub Desktop.
get outta here, warnings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ("stringi" %in% utils::installed.packages()) { | |
| flip <- stringi::stri_unescape_unicode('(\\u256f\\u00b0\\u25a1\\u00b0\\uff09\\u256f\\ufe35 \\u253b\\u2501\\u253b') | |
| warnings <- function(...) base::warnings(flip) | |
| } |
Also best practices to test if an optional package is available is
if (requireNamespace("stringi", quietly = TRUE)) { }See the note section of ?installed.packages for reasons why.
Note:
This can be slow when thousands of packages are installed, so do not use this to find out if a named package is installed (use ‘system.file’ or ‘find.package’) nor to find out if a package is usable (call ‘require’ and check the return value) nor to find details of a small number of packages (use ‘packageDescription’). It needs to read several files per installed package, which will be slow on Windows and on some network-mounted file systems.
Author
Awesome, thank you for these and for taking the time. Very happy to learn better practices while I learn ... worse practices.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need stringi, just use the escapes directly