[R] multiple variables pointing to single dataframe?

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Apr 19 16:21:31 CEST 2010


Hi,

On Mon, Apr 19, 2010 at 10:15 AM, Alex Bryant <abryant at i-review.com> wrote:
> Hi, for example:
>
>> x <- Orange
>> x2 <- x
>> x[1,]$age <- 50
>> x2[1,]
>  Tree age circumference
> 1    1 118            30
>
> I would like a way for x2 to also reference the modified x data frame without having to reassign x2<x each time x is modified.

You can't *really* do this in R, but I believe you can rig up a work
around using environments (if you really have to).

This SO thread with links is *somehow* related to what you're asking.
Perhaps you'll find what you're looking for there:

http://stackoverflow.com/questions/2603184/r-pass-by-reference

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list