[Roxygen-devel] [roxygen2] error sourcing the R files (probably environment issue)
Renaud Gaujoux
renaud at cbio.uct.ac.za
Wed Sep 21 15:41:51 CEST 2011
Hi,
in one of the R files I have something like this, that defines a
temporary function in order to define a static variable:
f <- function(){
.a <- 0
function(x=1){
.a <<- .a + x
.a
}
}
f2 <- f()
rm(f)
When running roxygenise on this I get the error:
Error in eval(expr, envir, enclos) : object 'f' not found
No error with R CMD check.
If I use the -- very nice -- function devtools::load_all, it works
perfectly fine as well.
In this simple case I know I could do f <- f() instead and remove the
problematic call to rm (and it works fine).
But my actual use case is to define a S4 method like this:
setMethod('A', 'ANY', f())
rm(f)
Here I really need to remove not to have it remaining in my namespace.
Does roxygen2 source the R files differently?
Maybe there is an alternative way to define static variables for my use
case, that would not break roxygenise?
Thank you
Renaud
###
UNIVERSITY OF CAPE TOWN
This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity.
###
More information about the Roxygen-devel
mailing list