Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Require' returns uninformative error if package is already loaded [minor] #92

Closed
tati-micheletti opened this issue Jan 7, 2019 · 1 comment

Comments

@tati-micheletti
Copy link
Contributor

reprex:

reproducible::Require(raster) # works fine
reproducible::Require(raster) # Error in Require(raster) : packages should be a character vector or a name
@eliotmcintire
Copy link
Contributor

eliotmcintire commented Jan 7, 2019

That is actually very imformative, and solves your problem:

reproducible::Require(raster) # works fine
reproducible::Require(raster) # Error in Require(raster) : packages should be a character vector or a name
reproducible::Require("raster") # works fine, with no error or message

It "tries" the first time to use the "object" called raster... since it does not exist, it tries to interpret it as a character string. The second time, the package is loaded, so the "object" called raster does exist. So, it tries to load that object (it is the function raster::raster). The third, and correct time, is the best way to always load a library/package in R. It does "work" in base R to use require(raster) ... but that not great for Require for some other reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants