From jeff.a.ryan at gmail.com  Fri Feb  4 20:42:22 2011
From: jeff.a.ryan at gmail.com (Jeff Ryan)
Date: Fri, 4 Feb 2011 13:42:22 -0600
Subject: [Rd] matching symbols to objects
In-Reply-To: <AANLkTindUsvryMwCr2=rdfTxyf_J-cAAL+aFrSpEw23_@mail.gmail.com>
References: <AANLkTindUsvryMwCr2=rdfTxyf_J-cAAL+aFrSpEw23_@mail.gmail.com>
Message-ID: <AANLkTi=4NuSJLMFXCTC8W1hD_nQXrTjtNG9fxMvDpQ84@mail.gmail.com>

Patrick,

Take a look at all.vars to start with  That will return the vars as
characters, from there you can use get to test/proceed.

> all.vars(parse.tree)
[1] "x"


Best,
Jeff

On Fri, Feb 4, 2011 at 1:37 PM, Patrick Leyshock <ngkbr8es at gmail.com> wrote:
> Hello,
>
> I'm trying to access an object, given only its name as a symbol. ?I cannot
> figure out how to proceed. ?Suppose I call substitute( ) on the expression
> 'x + 2':
>
>> parse.tree <- substitute(x + 2);
>
> The constituents of parse.tree are of type symbol and numeric:
>
>> str(parse.tree[[1]])
> symbol +
>
>> str(parse.tree[[2]])
> symbol x
>
>> str(parse.tree[[3]])
> num 2
>
> Suppose that x is S4 object, and that I need to access a slot of that
> object. ?How can I do so, using only 'parse.tree' (or parse.tree coerced
> into a list)?
>
> Thanks, Patrick
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com



[Rd] matching symbols to objects
Jeff Ryan