[R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Mon Oct 24 18:34:08 CEST 2022
В Mon, 24 Oct 2022 12:07:44 -0400
Kelly Thompson <kt1572757 using 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
More information about the R-help
mailing list