Created
July 8, 2016 19:19
-
-
Save RobertMyles/96665be044540e9ac668ee697dac6db7 to your computer and use it in GitHub Desktop.
Load multiple packages at the same time in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# library() or require() only load one package at a time | |
# but... | |
Packages <- c("dplyr", "ggplot2", "rstan", "readr") | |
lapply(Packages, library, character.only = TRUE) | |
# this loads as many as you put in 'Packages'. They need to be installed first, of course. |
Thanks for the share! much convenient than pacman::
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for tip @RobertMyles 👍
I usually use
pacman::p_load()
, but just realized during RStudio Connect deployment, it'll attempt to re-install every packages, regardless if it's installed or not!I checked
xfun::pkg_attach()
, and it seems it has a checkxfun::loadable()
, which should avoid the above.