I am writing a package that does some work on a server. I have a script that updates a table but my intention was not to run it manually and infrequently. It's not a function that needs to go into the namespace or anything, just a script.
The problem is that when I call roxygen2::roxygenize()
it runs this script and takes a while to run which is very annoying while I'm trying to develop the interactive functions. I know that I can add \donotrun{}
around the examples in my documentation but that doesn't quite make sense in this context. Is there a way that I can tell roxygen to not bother executing this?
I considered making this a function just so that executing it would just define the function body but that seems a little sideways.
Any suggestions would be great
For new visitors, this is not code within roxygen documentation for a function; for that, it would be best to surround it with \dontrun
, as in
#' @examples
#' \dontrun{
#' something_goes_here()
#' }
myfunction <- function(...) {
In this case, though, it's including some files in the package itself.
Files you place within the ./inst/
directory are installed with the packages, but they are not assumed to be R scripts (or anything, for that matter). The authoritative reference for this starts with "Writing R Extensions", Section 1.1.5 Package sub-directories. This will install the file(s) on each computer that installs the package via install.packages(...)
.
If you want something within the package source but not to be installed with the package itself, I suggest you place a file in the root of the package named .Rbuildignore
(ref: same link, now section 1.3.2 Building package tarballs). Files that are matched by these patterns will not be included in the package tarball. Whether you put the actual file within ./inst/
or anywhere else is completely up to you: if it is in the .Rbuildignore
file, then it will be excluded from the tarball (and therefore seen/findable by the end users).