Search code examples
rrstudiodevtools

devtools equivalent of RStudio Build panel buttons


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?


Solution

  • In RStudio you can check "Use devtools package functions if available" in Project Options > Build Tools and you can see what devtools functions will be used. If you look at the build console pane, you can check out what RStudio runs. General cases if using devtools:

    • Build & Reload

      • devtools::build()
      • devtools::reload() is possibly an option but Rstudio uses R CMD INSTALL --no-multiarch --with-keep.source <pkgNameGoesHere>
    • Check

      • devtools::check()
    • Load All
      • devtools::load_all(".")
    • Clean and Rebuild
      • R CMD INSTALL --preclean --no-multiarch --with-keep.source <pkgNameGoesHere>
    • Test Package
      • devtools::test()
    • Check Package
      • devtools::check() (same as Check button)
    • Build Source Package
      • devtools::build()
    • Build Binary Package
      • devtools::build(binary = TRUE, args = c('--preclean'))

    More info at the readme in the devtools repo.