[R] Convert text string to object pointer

Henrik Bengtsson hb at stat.berkeley.edu
Fri Aug 15 17:05:56 CEST 2008


See the Object class in the R.oo package.  /Henrik

On Thu, Aug 14, 2008 at 7:35 PM, Abiel Reinhart <abielr at gmail.com> wrote:
> I would like to use a text string to get a reference to an object whose name
> is the text string. I have seen people using get() for this purpose, but as
> far as I can tell this returns a copy of the object, not a pointer to the
> object. For instance, if I were to write
>
> x <- get("z")
> attr(x, "age") <- "fifty"
>
> Then x would have the attribute "age" attached to it, but z would not. I
> would like z to change when I change x. Does anyone have a suggestion on how
> to do this? The context for this question is an application in which object
> attributes are listed in an XML file, with each set of attributes having a
> key which refers to the name of an object in R.
>
> Thank you,
>
> --
> Abiel Reinhart
> email: abielr at gmail.com
> cell: 541-514-1115
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list