[R] How to modify object's code living in some environment?

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Dec 27 14:17:14 CET 2021


On Mon, 27 Dec 2021 14:06:49 +0100
Grzegorz Smoliński <g.smolinski1 using gmail.com> wrote:

> I know it is possible to find the environment in which some object
> lives using the 'environment()' function

That's not exactly what environment() does. This function returns the
environment belonging to a function (where it searches for its
variables), not where it's defined. A function may have many names, but
only one "own" environment (plus its parent, plus the parent's parent
and so on).

You'll need to modify some other environment, where the function
actually lives, to make this work.

Is the shiny app a package? Perhaps trace() could help you? Modifying
package environments is even trickier.

-- 
Best regards,
Ivan



More information about the R-help mailing list