First, here's the specific bug I have. Later I'll say why I care.
> ls(zappo)
Error in try(name) : object "zappo" not found
# good.
> f = function(zappo) { function(y) zappo + y }
> g = f(1)
> g(1)
[1] 2
> formals(g)
$y
> formals(g)$y
> formals(g)$y = 2
> g
function (y = 2)
zappo + y
> g(1)
Error in g(1) : object "zappo" not found
# looks like formals strips the environment off stuff.
anything I can do about this?
-Alex
Original question:
I'm trying to change the behaviour of a package, to simplify the
interface.
I'd rather not change the package, although I could.
There's a hidden function whose defaults I wish to change.
I'm using R 2.3.1 for macosX. Upgrading is not an option.
This is what I do:
library(R2HTML)
# get the function to modify
x = getFromNamespace("HTML.data.frame", "R2HTML")
# change the default for an argument
formals(x)["Border"]=list(NULL)
# put the function back
assignInNamespace("HTML.data.frame", x, "R2HTML")
#test the function:
HTML(data.frame(1:2), file=stdout())
Error: could not find function "HTMLReplaceNA"
# what seems to be happening is that the formals function is
stripping the namespace off the variable x. I can't tell why.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.