[R] evaluate a string

Mike Lonergan mel at mcs.st-and.ac.uk
Wed Jun 26 12:57:44 CEST 2002


eval(parse(text="d<-4+7")) might do the trick.
parse turns the text into an expression then eval evaluates it.

Cheers,

mike.

     > -----Original Message-----
     > From: owner-r-help at stat.math.ethz.ch
     > [mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Joerg Maeder
     > Sent: 26 June 2002 10:06
     > To: R Help
     > Subject: [R] evaluate a string
     >
     >
     > Hello together
     >
     > i want to execute different commands that are saved in
     > strings (eg: "d
     > <- 4+7" and some more complicated things). How can i execute/evaluate
     > them. I know i could save them to a temp-file a read this
     > with source.
     > But is there a way without a file in the middle?
     > I know also the 'assign' command but I think it would only the simply
     > cases.
     >
     > thanks and gruess
     >
     > joerg
     >
     > --
     > Joerg Maeder    .:|:||:..:.||.::   maeder at atmos.umnw.ethz.ch
     > Tel: +41 1 633 36 25   .:|:||:..:.||.::
     > http://www.iac.ethz.ch/staff/maeder
     > PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH)
     > ETH ZÜRICH Switzerland
     > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
     > .-.-.-.-.-.-.-.-.-
     > r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list