Reputation: 4314
I'm creating an internal package, and one of the functions I want is to load all the packages we use commonly. If I include them in depends, the functions are available to my packages functions, but what I want it for them to be in the search path.
Basically I want to do what the tidyverse package does (loading all the core tidyverse packages for use in the global env). I've looked through the tidyverse code, and I cannot find the line that does the actual loading - all the functions appear to be either cosmetic (the awesome, colorful startup messages) or utilties. The .onAttach
seems like where it would be, but nothing there appears to actually attach the other packages.
If there is a simpler way than how tidyverse does it, that's great, but I'm also curious about that method.
Upvotes: 1
Views: 370
Reputation: 13128
.onAttach
calls tidyverse_attach()
(https://github.com/tidyverse/tidyverse/blob/master/R/zzz.R#L7), which loads packages using library
(https://github.com/tidyverse/tidyverse/blob/master/R/attach.R#L37-L39).
Upvotes: 3