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 my_data.Rda
in the Data
folder, and when the package is loaded I can access it in the Console, for instance by using data(my_data)
.
My problem comes when, using usethis::use_vignette("my_vignette")
, I want to include something like this (much more complex in practice, of course) in the vignette:
The mean of my_data is given by
```{r} data(my_data)
mean(my_data)
```
When I knit the vignette I get the message
"Error in assert_engine(is_numeric, x, .xname = get_name_in_parent(x), : object 'my_data' not found"
I have looked at this post: How to add external data file into developing R package? but that addresses external data.
What am I doing wrong?
I have created a minimal R package with the relevant Rmd file in the vignettes folder. link to Github