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? Thanks you for any help Vincent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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)) 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sat, Sep 21, 2002 at 01:48:56PM +0200, 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?I do not know luch of MATLAB, but the following should do it: get(s) Hopin' it helps L.> > Thanks you for any help > Vincent > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._