1

I found this post on how to install and load missing packages, which was helpful. However, I was wondering if I always have to write out the packages or if you somehow can do this when the code contains a list of "library()" like this:

library(ggplot2) 
library(rugarch)
library(PortfolioAnalytics)
library(tidyverse)

Because that's how it usually looks like when someone is sharing code with you and it'd be great if it was possible to simply write some code around it and not having to copy-paste every package name into the appropriate code.

NoNameNo123
  • 625
  • 1
  • 8
  • 17
  • R intentionally keeps the process of installing and loading packages separate because installing "updated" version of packages might change behavior that you depend on and could break things. It's not always a great idea to try to update all your packages. You could write your own version of `library()` but it's usually not a great idea to shadow built in functions. If scripts have a lot of dependencies, it's probably best to turn them into packages which can declare dependencies so they are are easier to load. – MrFlick Apr 22 '19 at 15:32

0 Answers0