[R] "Executing" a string

Jan Goebel jgoebel at diw.de
Wed Oct 11 14:51:14 CEST 2000


On Wed, 11 Oct 2000, Thomas Hoffmann wrote:

> In Matlab or Octave I can evaluate (evalf) the content of
> a string. In R I have looked around in the docs, but have not 
> found a way to do something equivalent (which is possible, I think).
> 
> Can anybody give me a pointer?
> 

May be your looking for somethig like:

> example <- seq(0,5)
> string  <- "example"
> as.name(string)
example
> eval(as.name(string))
[1] 0 1 2 3 4 5

Hope this helps

jan
-----------------------------------
Jan Goebel (mailto:jgoebel at diw.de)

DIW German Institute for Economic Research
SOEP
Königin-Luise-Str. 5
D-14195 Berlin
Germany

phone: 49 30 89789-377
-----------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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