Re: [R] Calling the curve function with a character object converted into an expression

2018-05-03 Thread Sebastien Bihorel
"Sebastien Bihorel" Cc: "R-help" 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

Re: [R] Calling the curve function with a character object converted into an expression

2018-05-02 Thread Bert Gunter
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

Re: [R] Calling the curve function with a character object converted into an expression

2018-05-02 Thread Bert Gunter
Sebastian: This is somewhat arcane, perhaps even a bug (correction on this welcomed). The problem is that the "expr" argument to curve() must be an actual expression, not a call to parse that evaluates to an expression. If you look at the code of curve() you'll see why (substitute() does not evalu

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

2018-05-02 Thread Sebastien Bihorel
Hi, Down a cascade of function calls, I want to use the curve function with an expression that is a variable. For various reason, this variable must be a character object and cannot be an expression as required by the curve function. How do I convert my variable into a expression that is accep