Skip to content
Prev 374421 / 398528 Next

Calling the curve function with a character object converted into an expression

Thanks,

I always get confused by expression evaluation, when and how to use call, do.call, eval, parse/deparse, and all that good stuff. I always have to read documentation 10 times and still does not want to stick in my brain.

----- Original Message -----
From: "Bert Gunter" <bgunter.4567 at gmail.com>
To: "Sebastien Bihorel" <sebastien.bihorel at cognigencorp.com>
Cc: "R-help" <r-help at r-project.org>
Sent: Thursday, May 3, 2018 2:28:59 AM
Subject: Re: [R] Calling the curve function with a character object converted into an expression

Typo: should be NULL not NUL of course

An alternative approach closer to your original attempt is to use
do.call() to explicitly evaluate the expr argument:

w <- "1 + x^2"
do.call(curve, list(expr = parse(text = w), ylab ="y"))

Cheers,
Bert

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 Wed, May 2, 2018 at 10:35 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote: