See here for almost the same issue:

http://r.789695.n4.nabble.com/Pasting-R-code-lines-into-labels-td4757446.html

Same answer: pass the unevaluated formula (i.e. an R expression) using
substitute/quote. Then evaluate it appropriately using eval. Same
references.

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 Thu, Jun 6, 2019 at 11:08 AM Frank S. <f_j_...@hotmail.com> wrote:

> Dear all,
>
> I have defined an R function g(y) wich in turn is inside other R function
> f(x). The function g(y) depends on an
> equation, and I would like to know if such an equation could be passed as
> an argument of the main function
> (taking into account that we should change the variable "x" to "y").
> As an example, I have:
>
> function(x) {         # Main function, called f(x)
>
>   -----  (code)
>
>   function(y) {        # Sub-function, called g(y)
>     -----  (code)
>     eq <- y^2 -3*y
>     ----- (code)
>   }
>
>   ----- (code)
>
> }
>
> In summary, I would like to know is there is any way to:
> Put the equation "eq" as an argument of the main function f(x).
>
>
> Thank you very much!
>
> Frank
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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