[R] substitute in a named expression

From: Søren Højsgaard <Soren.Hojsgaard_at_agrsci.dk>
Date: Thu 23 Jun 2005 - 07:33:03 EST

I have a 'named expression' like
  expr <- expression(rep(1,d))
and would like to replace the argument d with say 5 without actually evaluating the expression. So I try substitute(expr, list(d=5)) in which case R simply returns expr which when I 'evaluate' it gives  eval(expr)
 Error in rep.default(1, d) : invalid number of copies in rep()

I've looked at ?substitute and ?expression (and other places) for ideas, but - well I guess there are some details which I haven't quite understood. Can anyone point me in the right direction? Thanks

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 23 07:35:59 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:57 EST