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

test if data.table installed. #2

Open
jimrothstein opened this issue Apr 12, 2022 · 2 comments
Open

test if data.table installed. #2

jimrothstein opened this issue Apr 12, 2022 · 2 comments

Comments

@jimrothstein
Copy link

Not very important ....

Now:

install.packages("data.table")

Suggest:

if (!require("data.table", quietly=T)) install.packages("data.table")

@LucyNjoki
Copy link
Owner

Do I understand correctly that the package will be installed, but the startup message will be turned off?

@jimrothstein
Copy link
Author

jimrothstein commented Apr 13, 2022

From https://stat.ethz.ch/R-manual/R-devel/library/base/html/library.html:

require returns (invisibly) a logical indicating whether the required package is available.

So I use require as test if installed, true or false, with no warning message.

To turn off messages during actual install.packages, I use quiet=T
https://stat.ethz.ch/R-manual/R-devel/library/utils/html/install.packages.html

fyi - I know lots and lots of ways to lookup R, but I find going directly to ref manual often gives me idea. (not the way to LEARN, only to get the story straight)
https://stat.ethz.ch/R-manual/R-devel/library/ (then choose base:: or whatever package)

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