At my company I created a package for plot formatting, but we use font Roboto, which we have to load in R every time. Is there a way to make extrafont::loadfonts(device="win") an automatic response when someone runs library(ourpackage).
I am thinking something similar to .Rprofile but pushing it into a package.
Occasionally, packages do need side-effects. This is most common if your package talks to an external system — you might need to do some initial setup when the package loads. To do that, you can use two special functions: .onLoad() and .onAttach() . These are called when the package is loaded and attached. You’ll learn about the distinction between the two in Namespaces. For now, you should always use .onLoad() unless explicitly directed otherwise.
For an alternative workflow without the extrafont package see the overview Setting up and debugging custom fonts that uses ragg. Now, of course if you are otherwise happy with extrafont, no need to switch.