Created
April 16, 2017 05:26
-
-
Save jlmelville/72fff16e428559f213d5e73a31169301 to your computer and use it in GitHub Desktop.
Loading a development package for use in a vignette (e.g. in RStudio)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r setup, include=FALSE} | |
devtools::load_all("..") | |
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>") | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Writing a vignette is a great way to discover how terrible and inconvenient the API of your R package is. I recommend it highly. But you can't knit a vignette if the package isn't installed, and you will also be churning through several different versions of your code as you reduce the pain associated with using it. My workflow in RStudio therefore involves lots of use of
devtools
to reload my package via Ctrl-Shift-L.However, re-knitting a vignette requires it to pick up the devtools version of the package, which it won't do by default. It probably should have been obvious that you need to replace:
library(my_library_name)
with:
but it was surprisingly hard to find a web page that outright states this. A comment to the following question on stack overflow finally provided the answer:
http://stackoverflow.com/questions/35727645/devtools-build-vignette-cant-find-functions
but I can never remember this for some reason. Hence this gist. Just remember to swap back to using
library
before you check in!