Hi,

I know it is possible to find the environment in which some object
lives using the 'environment()' function and the name of this object,
but how to modify code of this object after this? Below is MRE:

test <- function() 1

test() # 1

environment(test)$test <- eval(parse(text = "function() 2"))

test() # still 1

.GlobalEnv$test <- eval(parse(text = "function() 3"))

test() # 3

The context is I have shiny app which code I would like to modify (add
something) and the only way to refer to this environment I know is to
use 'environment()' (as I see, those functions do not live in
.GlobalEnv), but as you can see above, I can't use it to modify the
code.

Best regards,

Grzegorz Smoliński

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to