简体   繁体   中英

ignore script with roxygen2

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 \donotrun , as in

#' @examples
#' \donotrun{
#' something_goes_here()
#' }
myfunction <- function(...) {

In this case, though, it's including some files in the package itself.

  1. 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(...) .

  2. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM