Loading all installed packages of library

Hi,
Is it possible to load all installed packages in R in one go?

Thank you!

Khurram

Yes, but that wouldn't bee a good idea, you would be consuming time and memory unnecessarily and you would also found a lot of name conflicts, anyways this is how you could do it.

# Listing packages
packages <- installed.packages()

# Loading first 5 packages for testing
lapply(packages[1:5], require, character.only = TRUE)
2 Likes

Since I've gone to all this trouble to actually make it work, I did it this way:

library(magrittr)
list.files(.libPaths()[1])  %>%
  purrr::walk(~library(.x, character.only = TRUE))

I have to agree with @andresrcs that it is likely a very bad(:tm:) idea. However, it did force me to fix few problems with packages I've had since like forever :slight_smile:

Thank you andrescs and mishabalyasin!

I have found following command which works to load all installed package of library:

lapply(.packages(all.available = TRUE), function(xx) library(xx,character.only = TRUE))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.