How to add external data file into developing R package?
<p>I am building my R packages in Rstudio, I ran into some unexpected problem when I tired to create package' vignette. when I hit build/load panel in Rstudio, I got vignette error, while package's documentation was created. To possibly solve vignette error I got, I have to add external data to my packages, use this data to compile package vignette accordingly. I used <code>devtools::install()</code> command to install my packages, but <code>inst/</code> directory is not created. <code>extdata</code> must be located in <code>inst</code> directory. I also used <code>devtools::use_data()</code> to add my data from my PC, but I can't able to add my external data. How can I load external data for my packages ?  I think I should not manually create <code>extdata</code> and put external data over there. Why <code>inst/</code> was not created when I used <code>devtools::install()</code> ? How to add set of csv files as external data into my packages ?</p>
<p>This is the toy helper function I am going to use in my vignette to read external data :</p>
<pre><code>myFunc &lt;- function(myDir, ...) {
  files &lt;- list.files(myDir, full.names = TRUE, &quot;\\.csv$&quot;)
  readMe &lt;- lapply(files, read.csv)
  return(readMe)
}
</code></pre>
<p>This is the first time I build R packages, getting some common error. My apology if my questions is not well stated.</p>
<p>to find files in <code>inst/</code>, I need to use <code>system.file()</code>, but I don't have this directory, plus <code>myFunc</code> accept file directory to to grab the files and read them as .csv, this is toy code chunk could be executed in vignette file :</p>
<pre><code>```{r}
library(myPkg)
file.1 &lt;- system.file(&quot;extdata&quot;, &quot;xxx.csv&quot;, &quot;myPkg&quot;)
file.2 &lt;- system.file(&quot;extdata&quot;, &quot;yyy.csv&quot;, &quot;myPkg&quot;)
myFunc(list(file.1, file.2))

```
</code></pre>
<p>How can I load external data to my packages in order to compile package vignette by using this data ? Why <code>inst/</code> not created when I hit <code>devtools::install()</code> ? Can anyone help me how to do this ?Thanks in advance :)</p>