[R] paste an unevaluated expression

Gabor Grothendieck ggrothendieck at gmail.com
Mon Oct 18 05:38:09 CEST 2010


On Sun, Oct 17, 2010 at 9:14 PM, Lorenzo Cattarino
<l.cattarino at uq.edu.au> wrote:
> Hi R-users,
>
>
>
> I would like to create an expression without evaluating it. Then paste
> that expression to an object. Example:
>
>
>
> Result <- paste('Result', 1, sep="")
>
> paste(Result, substitute(apply(exp.des[1:10,], 1, one.row,
> parms=parameters)), sep="<-")
>
>
>
> However this pastes EACH element of the unevaluated expression. Instead
> I just would like the expression to be a character string, with just ONE
> element.

Try this:

s <- substitute(...whatever...)
paste(Result, format(s), sep = "<-")

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list