[R] need help for eval()

Laurent Gautier laurent at cbs.dtu.dk
Sat Sep 21 18:15:24 CEST 2002


On Sat, Sep 21, 2002 at 04:21:39PM +0200, Uwe Ligges wrote:
> demolombe wrote:
> > 
> > Hello,
> > 
> > I need help, after hours trying to do it myself,
> > to do the following:
> > 
> >     I have an object, named, say,  F1   from a class "fichier"  that I buildt.
> >     this F1 has a slot named datas   ,which is a vector, so I can access to
> > : F1 at datas[1], F1 at datas[2], ...
> > 
> >     Now I have a string s="F1 at datas[1]" and need to retreive the real
> > content of F1 at datas[1] using s.
> > 
> >     Is there a way to do this, as it is in Matlab?
> 
> 
> E.g., you'll get the value by 
> 1) coercing the string to an expression, and
> 2) evaluating that one.
> 
>  eval(parse(text = s))



I just realized I should have sit on my hands and count to 7 before
touching the 'return' key... one more time...

By luck the *right* answer was sent before I even had to send a
correction to mine.

Sorry for the mistake.



> 
> You can get access to particular slots by slot(), but that's another
> topic, since your character string describes much more than that.
> 
> Uwe Ligges
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
--------------------------------------------------------------
Laurent Gautier			CBS, Building 208, DTU
PhD. Student			DK-2800 Lyngby,Denmark	
tel: +45 45 25 24 89		http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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