[R] Can I execute the content of a character vector?

Roger Bivand Roger.Bivand at nhh.no
Mon Nov 13 19:36:22 CET 2006


On Mon, 13 Nov 2006, Luiz Rodrigo Tozzi wrote:

> Hi
> 
> I want to know if there is any possibility of "executing" the content of a
> vector, for example:
> 
> example=c("Test",1,0,0,0,"seq(14,42,by=2)",0,0,1)
> 
> i want to know if there is anything like "execute(example[6])"

You can say:

eval(parse(text=example[6]))

but it is difficult to avoid shooting people in the feet with it, unless 
that is what you want ...

eval(parse(text=example[1]))


> 
> i really need this because this object example is created from a parameter
> file with names, flags and this "seq" somethimes will be something like
> c("1","99,"3") or even c("")
> 
> executing the content would be an easier step for me
> 
> thanks!
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-help mailing list