[R] name scoping within dataframe index
Alexy Khrabrov
deliverable at gmail.com
Mon Jan 26 20:20:55 CET 2009
On Jan 26, 2009, at 2:12 PM, Duncan Murdoch wrote:
>>> df[get("colname", parent.frame()) == value,]
>> Actually, what I propose is a special search rule which simply
>> looks at the enclosing dataframe.name[...] outside the brackets
>> and looks up the columns first.
>
> Yes, I understood that, and I explained why it would be a bad idea.
Well this is the case in all programming languages with scoping where
inner-scope variables override the outer ones. Usually it's solved
with prefixing with the outer scope, outercsope.name or
outerscope::name or so. So it only underscores the need to improve
scoping access in R.
Dataframe column names belong to the dataframe object and the natural
thing would be to enable easy access to naming; you'd need to apply an
extra effort to access an overridden unrelated external variable.
Again, just an analogy from other programming languages.
Cheers,
Alexy
More information about the R-help
mailing list