title: R: How to run some code on load of package?
body: <p>I am learning to build a package for R. Now to set it up I need to run some code when the package is being loaded via <code>require(myPackage)</code>.</p>
  
  <p>I read the documentation on <code>help(".onLoad")</code> that just made me really confused as there is no example. How do I actually use <code>.onLoad</code>?</p>
  
  <p>Can someone please show me a simple example? For example I know <code>export(myfun)</code> in the NAMESPACE file will export <code>myfun</code> for use, what is the code that I need to run say <code>rnorm(10)</code> at package load?</p>