[R] building an expression
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed May 7 17:17:53 CEST 2003
On 7 May 2003, michaell taylor wrote:
[...]
> I am close, but not quite there. I am left with the eq object:
> > eq
> [1] "0.0188900087591286" "d1$b * -0.0192141899003632"
> [3] "d1$c * 0.158235007749465"
>
> which needs converting into a single eval() 'able. seems like some sort
> of do.call(expression, eq) sort of construction is the way to go, but
> clearly I am not getting the syntax correct.
parse(text=paste(eq, collapse="+"))
would give you the expression
0.0188900087591286 + d1$b * -0.0192141899003632 + d1$c * 0.158235007749465
which appears to be what you want (although you did not say addition was
involved: you also seem to be assuming a linear model in [...]).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list