What is the correct way to go about automatically running some setup code (either in R or C++) once per package loading? Ideally, said code would execute once the user did library(mypackage)
. Right now, it's contained in a setup()
function that needs to be run once before anything else.
Just for more context, in my specific case, I'm using an external library that uses glog and I need to execute google::InitGoogleLogging()
once and only once. It's slightly awkward because I'm trying to use it within a library because I have to, even though it's supposed to be called from a main
.