I'm trying to install an R package from a private repository on GitHub
. Package objects, such as data
and functions
, are downloaded as they should, but I'm missing the vignettes
, i.e. the .Rmd
that is located in the /vignettes
folder of the package.
library(devtools)
devtools::install_github("person_name/repo_name", build_vignettes = TRUE, auth_token = "xxx")
My goal is to be able to download both functions
, data
and the .Rmd
from the package using install_github()
.
Ideally, the functions
and data
from the package would be in the RStudio memory (which works fine), while the .Rmd
file should be downloaded locally to the directory I'm in when I download the package.
The purpose is to make it easy for a user to re-run the analysis (the .Rmd
) with the included data
and functions
.
Is this possible or have I misunderstood the function?
Vignettes are not stored in the local working directory. They are stored in the package bundle itself. You typically access them using
vignette("topicname", package="packagename")
If you want to get the path to that RMD file (assuming the source file is a markdown file which is not the case for all packages), you can write a little helper
get_vignette_source_path <- function(...) {
v <- vignette(...)
file.path(v$Dir, v$File)
}
For example with the dplyr
"colwise" help
get_vignette_source_path("colwise", package="dplyr")
You could also have it copy the file to your working directory
file.copy(get_vignette_source_path("colwise", package="dplyr"), ".")
You could include a function in your package to do this if you like. you can also actuyally open an edit window for the source file itself with
edit(vignette("colwise", package="dplyr"))
and then the user could save that value where they like.