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

2021-12-27 Thread Duncan Murdoch
On 27/12/2021 8:25 a.m., Duncan Murdoch wrote: On 27/12/2021 8:06 a.m., Grzegorz Smoliński wrote: 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

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

2021-12-27 Thread Ivan Krylov
On Mon, 27 Dec 2021 15:36:01 +0100 Grzegorz Smoliński wrote: > write on the beginning of the body of this chosen function > 'browser()'. Is your desired result similar to what debug() (or debugonce()) does? Perhaps you won't even need to construct a call and evaluate it in a given environment f

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

2021-12-27 Thread Bert Gunter
I think ?body, especially the replacement form body<-, might be what you are looking for. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Dec 27, 2021 at 5:

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

2021-12-27 Thread Grzegorz Smoliński
Thank you, Ivan and Duncan. The truth is I still feel lost in this concept of environments, generally speaking. What I really thought about is the possibility to make a shiny app where there will be possible to choose the function name (from the set of all functions defined in this app / modules /

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

2021-12-27 Thread Duncan Murdoch
On 27/12/2021 8:25 a.m., Duncan Murdoch wrote: On 27/12/2021 8:06 a.m., Grzegorz Smoliński wrote: 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

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

2021-12-27 Thread Duncan Murdoch
On 27/12/2021 8:06 a.m., Grzegorz Smoliński wrote: 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: You are misunderstanding the relation

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

2021-12-27 Thread Ivan Krylov
On Mon, 27 Dec 2021 14:06:49 +0100 Grzegorz Smoliński 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 searche

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

2021-12-27 Thread Grzegorz Smoliński
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"