[R-pkg-devel] Issue with closures & devtools::document/check
James Toll
james at jtoll.com
Sun Jun 28 21:13:56 CEST 2015
Hi,
I’m working on putting together a package of some functions I’ve been using and I’m running into an issue with closures. I’m using Rstudio and devtools. Here is a simple example that shows the problem I’m having.
file: R/testClosure.R
#' Test Closure
#'
#' This function is an example of a closure.
#'
#' @param y a number.
#'
#' @return A function.
#' @export
testClosure <- function (y) {
function (x) {
x ^ y
}
}
file: R/square.R
#’ Square a number
#'
#' This function squares a number.
#'
#' @param x a number.
#'
#' @return A number.
#' @export
sq <- testClosure(2)
If I try to run document() or check() from devtools, I get these errors.
> document()
Updating pda documentation
Loading pda
Error in eval(expr, envir, enclos) (from square.R#9) :
could not find function "testClosure"
> check()
Updating pda documentation
Loading pda
Error in eval(expr, envir, enclos) (from square.R#9) :
could not find function “testClosure"
If I create something similar, that’s not a closure, I don’t have any path issues finding the other function. This seems to only happen when I try to use a closure. Any thoughts or suggestions on what might be happening here? Thank you.
James
More information about the R-package-devel
mailing list