[R] Read code from character string
Greg Snow
Greg.Snow at imail.org
Sat Jun 19 00:44:48 CEST 2010
There are a lot of other reasons to install the fortunes package that just the one fortune, there is much wisdom, some wit, (and then there are mine) throughout the package.
There could be other ways to accomplish your goals, if you let us know more about what you are trying to do, we may be able to help you find a better way (that does not mean that you cannot still use eval and parse, but you may learn something, and/or avoid future pitfalls).
> fortune(106)
If the answer is parse() you should usually rethink the question.
-- Thomas Lumley
R-help (February 2005)
> fortune('106')
Personally I have never regretted trying not to underestimate my own future
stupidity.
-- Greg Snow (explaining why eval(parse(...)) is often suboptimal, answering
a question triggered by the infamous fortune(106))
R-help (January 2007)
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: Johannes Huesing [mailto:johannes at huesing.name]
> Sent: Friday, June 18, 2010 2:57 PM
> To: Greg Snow
> Cc: Peter Langfelder; r-help at stat.math.ethz.ch
> Subject: Re: [R] Read code from character string
>
> Greg Snow <Greg.Snow at imail.org> [Fri, Jun 18, 2010 at 04:57:03PM CEST]:
> > You should also look at fortune(106) and think about possible other
> solutions to your overall objective.
>
> I am not installing fortune solely for this purpose but I understand
> that anything which smells like macro expansion is frowned upon in R
> circles.
>
> Yet there are situations where i want to treat code as data and
> data as code. As far as I gather this works only with closures in R,
> not with general S-expressions, so sometimes I have to resort to
> character strings.
>
> --
> Johannes Hüsing There is something fascinating about
> science.
> One gets such wholesale returns of
> conjecture
> mailto:johannes at huesing.name from such a trifling investment of fact.
> http://derwisch.wikidot.com (Mark Twain, "Life on the
> Mississippi")
More information about the R-help
mailing list