When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?
? Mon, 24 Oct 2022 12:07:44 -0400 Kelly Thompson <kt1572757 at gmail.com> ?????:
require( packages_i_want_to_use[1] )
#Error in if (!loaded) { : the condition has length > 1
This seems to be a bug in require(). In addition to understanding character strings as arguments, require() can load packages named by unquoted barewords: require(base) This uses non-standard evaluation, and the part that transforms an unquoted symbol into a package name doesn't expect to see what is effectively `[`(packages_i_want_to_use, 1) instead of a single symbol. If you pass the character.only = TRUE argument to require(), this additional handling is disabled, making your examples work again. It's a good idea to always pass this argument when calling require() with a variable as the first argument.
Best regards, Ivan