Message-ID: <20221024193408.04b8927e@arachnoid>
Date: 2022-10-24T16:34:08Z
From: Ivan Krylov
Subject: When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?
In-Reply-To: <CAHfBD2frpoHQ04bH5vGz8a_Fn2v1q1=i33doUkaqH5pk=5bevQ@mail.gmail.com>
? 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