Running a pre-build script when building an R package
Asked Answered
N

1

13

I have a package that uses both Rcpp and Roxygen2. I'd like to have R CMD build run a small prebuild script that runs compileAttributes() and and roxygenise() before it starting the build process. Is there a hook or mechanism to do this?

Neoimpressionism answered 18/5, 2014 at 15:54 Comment(1)
devtools is written to make these things easier.Leyden
C
7

As @mnel suggested, you could use a build script using devtools. Say a script named build.r:

library(devtools)
document()
compileAttributes()
someotherscript()
build()
Cimah answered 16/10, 2015 at 13:9 Comment(2)
could you clarify this a little more? The devtools package seems to run document() and the R CMD INSTALL when I click 'Install and restart'. Does it also look for a file named build.r?Magbie
No, the idea would be to make a script that you use when you want to build. The only way I can think of to trigger this using Rstudio is by making a custom add-in so you can use a keyboard shortcut.Cimah

© 2022 - 2024 — McMap. All rights reserved.