title: How to use an R package's own data when writing a vignette
body: <p>I have written most of an R package and now wish to write a vignette that uses my own data, that is already in the package. The data is correctly stored as <code>my_data.Rda</code> in the <code>Data</code> folder, and when the package is loaded I can access it in the Console, for instance by using <code>data(my_data)</code>.</p>
  
  <p>My problem comes when, using <code>usethis::use_vignette("my_vignette")</code> , I  want to include something like this (much more complex in practice, of course) in the vignette:</p>
  
  <blockquote>
    <p>The mean of my_data is given by</p>
  </blockquote>
  
  <pre><code>```{r} data(my_data)
  mean(my_data)
  ```
  </code></pre>
  
  <p>When I knit the vignette I get the message</p>
  
  <blockquote>
    <p>"Error in assert_engine(is_numeric, x, .xname = get_name_in_parent(x),
    :    object 'my_data' not found"</p>
  </blockquote>
  
  <p>I have looked at this post: <a href="https://stackoverflow.com/questions/40915385/how-to-add-external-data-file-into-developing-r-package">How to add external data file into developing R package?</a> but that addresses <strong>external</strong> data.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>I have created a minimal R package with the relevant Rmd file in the vignettes folder. <a href="https://github.com/jgcolman/mre/blob/master/mre/vignettes/my_vignette.Rmd" rel="nofollow noreferrer">link to Github</a></p>