devtools equivalent of RStudio Build panel buttons

Viewed 1242

I am making an R package using RStudio. I am comfortable using the buttons on the Build panel. I have a script that I would like to run each time I Build & Reload or Clean and Rebuild. I'd like to write a function that runs my script and then executes the devtools commands associated with one of those buttons, but I am having trouble finding documentation of the correspondence between those buttons and devtools commands. The buttons are as follows:

  • Build & Reload
  • Check
  • Load All
  • Clean and Rebuild
  • Test Package
  • Check Package
  • Build Source Package
  • Build Binary Package

For each of the items in that list, what devtools R code would I run to cause the exact same behavior?

2 Answers

To execute the Clean & Rebuilt action from RStudio inside R you can use the R function system() Executing

system("R CMD INSTALL 
--preclean 
--no-multiarch 
--with-keep.source <your_package_name>")

Executes the Shell command from within your R session. Be aware that you will have to refer to the correct location of your package if you run this outside the Package Project (e.g. from another project or session)

Related