I have some .Rdata files that contain saved functions as defined by approxfun().
Some of the save files pre-date the change to approxfun from package "base" to "stats", and so the body has
PACKAGE = "base"
and the wrong package causes the function to fail. I can fix(myfun) and simply replace "base" with "stats", but I want a neater automatic way.
Can I do this with gsub() and body() somehow?
I can get the body text and substitute there with
as.character(body(myfun))
but I don't know how to turn that back into a "call" and replace the definition.
(I know that a better solution is to have saved the data originally used by approxfun and simply recreate the function, but I wonder if there's a sensible way to modify the existing one.)