Load Multiple Packages at Once in R (Example)
In this tutorial, I’ll illustrate how to load several add-on packages with one line of code in the R programming language.
The article consists of these content blocks:
- Creation of Example Data
- Example: Load Multiple Packages at Once in R
- Video, Further Resources & Summary
Let’s dive right in.
Creation of Example Data
As a first step, we need to specify a vector of package names:
my_packages <- c("dplyr", "mice", "stringr") # Create vector of packages
We have stored the names of three packages in the character vector my_packages. In the next step, I’ll show how to load all of these packages at once…
Example: Load Multiple Packages at Once in R
If we want to load multiple packages at once to R, we can use a combination of the lapply() and require() functions:
lapply(my_packages, require, character.only = TRUE) # Load multiple packages
After running the previous R code, all packages in the vector my_packages are loaded to R.
Video, Further Resources & Summary
I have recently released a video on my YouTube channel, which shows the topics of this article. You can find the video below.
Furthermore, you may want to read the other posts of this homepage:
- Check if Package is Missing and Install Automatically
- Unload Package without Restarting R
- Introduction to the pacman Package in R
- Useful R Packages
- The R Programming Language
Summary: In this article you learned how to load a list of packages to RStudio. Please let me know in the comments below, in case you have further questions.
Â
Subscribe to the Statistics Globe Newsletter
Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.
Thank you!
Welcome to the Statistics Globe newsletter. From now on, I’ll send you regular emails about statistics, data science, AI, and programming with R and Python.
I’m Joachim Schork. On this website, I provide statistics tutorials as well as code in Python and R programming.
Statistics Globe Newsletter
Get regular updates on the latest tutorials, offers & news at Statistics Globe. I hate spam & you may opt out anytime: Privacy Policy.
Thank you!
Please check your email inbox and click the confirmation link to complete your subscription. If you don’t see the email within a few minutes, please also check your spam/junk folder.





