title: How to find location of package?
body: <p>I am building an R package (let's call it "pkg"), and would like to write a function that downloads a file from the internet and saves it in the "inst/extdata" directory in my package's directory.</p>
  
  <pre><code> download_file &lt;- function(link) { 
       path &lt;- ... # path to where "pkg" is stored
                   # something along the lines of ....../pkg
       download.file(link, paste(path, "inst/extdata", "newfile", sep = ""))
   }
  </code></pre>
  
  <p>Could you please help me get the "path"? While developing the package, I can just do "getwd()" -- however, when a user calls my package, her working directory might not be the pkg directory. In which case, how do I get the path to my package's directory?  </p>