[Rd] Very Long Expressions
Robert.McGehee at geodecapital.com
Sun Jan 23 20:04:01 CET 2005
I'm having some difficulties with evaluating very long expressions
(Windows/Linux 2.0.1), as seen below, and would greatly appreciate any
help, thoughts or work arounds. Let's say that I wanted to see what I
would get if I added 1 to itself 498 times. One way of doing this would
be to evaluate the expression 1+1+1+...
> eval(parse(text = paste(rep(1, 498), collapse = "+")))
However, if we try this with 499+ items we get no answer:
> a <- eval(parse(text = paste(rep(1, 499), collapse = "+")))
Error: Object "a" not found
And if this eval is passed to any other function, that function exits
without error and without returning and object.
So it seems that we've reached some upper limit of evaluation terms.
While the parser is able to correctly create the long expression, eval
does not successfully evaluate it.
My problem is that since the evaluator does not return an object, error,
or warning, I'm not able to easily code around this problem. Also, I've
thought of no easy way to "count" the terms in the expression to see
whether we've breached the upper limit or not.
If I were able to see if the eval would work on a particular expression,
one thing I had considered was to make an eval.long wrapper that peels
terms off the right hand side of an overly-long expression until every
sub-expression is legal.
Thus, to count to 600 I could just add the first 497 terms with the next
>eval(parse(text = paste(rep(1, 497), collapse = "+"))) +
eval(parse(text = paste(rep(1, 103), collapse = "+")))
But without an error or way of figuring out if the expression would even
be evaluated, I'm not sure how to know when to start or stop the peeling
process. It also may become more complicated when parentheses are
Any help would be greatly appreciated.
system i386, mingw32
Geode Capital Management, LLC
53 State Street, 5th Floor | Boston, MA | 02109
Tel: 617/392-8396 Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com
This e-mail, and any attachments hereto, are intended for use by the
addressee(s) only and may contain information that is (i) confidential
information of Geode Capital Management, LLC and/or its affiliates,
and/or (ii) proprietary information of Geode Capital Management, LLC
and/or its affiliates. If you are not the intended recipient of this
e-mail, or if you have otherwise received this e-mail in error, please
immediately notify me by telephone (you may call collect), or by e-mail,
and please permanently delete the original, any print outs and any
copies of the foregoing. Any dissemination, distribution or copying of
this e-mail is strictly prohibited.
More information about the R-devel