[R] evaluation question

peter dalgaard pdalgd at gmail.com
Wed Nov 23 17:24:36 CET 2011

On Nov 23, 2011, at 00:24 , Rolf Turner wrote:

>> library(fortunes)
>> fortune("parse()")
> The fortune notwithstanding I find this *specific* use of parse() to be
> very, uh, useful! :-)

The fortune does say "usually", and there certainly are exceptions, for instance the use in Rcmdr where you edit and submit code from the log window.

What to avoid is something like this:

value <- 3.2; r <- 1
cmd <- paste("pexp(",value,",rate=",r,")")



would do. Or, if you do need the unevaluated expression:


(I believe we still have a couple of cases in the standard R code where the code does something like

rhs <- paste(vnames, sep="+")

and then proceeds to parse it and put the result into the right hand side of a model formula. It works (mostly) but it hurts my eyes seeing computing on the language done via the textual representation.)

Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-help mailing list