[R] multiple variables pointing to single dataframe?
Alex Bryant
abryant at i-review.com
Tue Apr 20 15:01:21 CEST 2010
That's great, that will work perfectly..
Thanks All!
-Alex
-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com]
Sent: Monday, April 19, 2010 10:34 AM
To: Alex Bryant
Cc: r-help at r-project.org
Subject: Re: [R] multiple variables pointing to single dataframe?
If you only need to retrieve x by referring to x2 and you don`t have
to modify x via x2 then this works:
> x <- Orange
> makeActiveBinding("x2", function() x, .GlobalEnv)
> x$age <- 50
> head(x2)
Tree age circumference
1 1 50 30
2 1 50 58
3 1 50 87
4 1 50 115
5 1 50 120
6 1 50 142
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.
>
> Thanks,
> Alex
>
> -----Original Message-----
> From: Petr PIKAL [mailto:petr.pikal at precheza.cz]
> Sent: Monday, April 19, 2010 3:18 AM
> To: Alex Bryant
> Cc: r-help at r-project.org
> Subject: Odp: [R] multiple variables pointing to single dataframe?
>
> Hi
>
> r-help-bounces at r-project.org napsal dne 16.04.2010 16:15:40:
>
>> Hi, I have a need to have 2 variables point to the same dataframe (d1),
> I
>
> What does it mean to point to data frame? Seems to me that it is something
> from C+.
>
> You can reference data frame by $ or by square brackets with as many
> variables as you want.
>
> see
>
> ?"["
>
> regards
> Petr
>
>
>> don't want to simply copy the dataframe ( d2<-d1 ) as my understanding
> is that
>> this will create a second dataframe. Any suggestions on best practice
> here?
>>
>> Thank You,
>>
>> //************************
>> // Alex Bryant
>> // Software Developer
>> // Integrated Clinical Systems, Inc.
>> // 908-996-7208
>>
>>
>> ________________________________
>> Confidentiality Note: This e-mail, and any attachment
> to...{{dropped:13}}
>>
>> ______________________________________________
>> 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.
>
> ______________________________________________
> 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