[R] "Executing" a string

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Oct 11 16:16:14 CEST 2000

>> Can anybody give me a pointer?

> eval(parse(text="2+2"))
>[1] 4

>Also check out substitute(), as.name() et al. for other methods of
>manipulating expressions and function calls

You should also consider do.call() if the string is actually the name of
a function.

Paul Gilbert

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