On 1/26/2009 1:46 PM, Alexy Khrabrov wrote:
Every time I have to prefix a dataframe column inside the indexing brackets with the dataframe name, e.g.

df[df$colname==value,]

-- I am wondering, why isn't there an R scoping rule that search starts with the dataframe names, as if we'd said

with(df, df[colname==value,])

-- wouldn't that be a reasonable default to prepend to the name search path?

If you did that, it would be quite difficult to get at a "colname" variable that *isn't* the column of df. It would be something like

 df[get("colname", parent.frame()) == value,]

So just use subset(), or with(), or type the extra 3 chars.

Duncan

______________________________________________
R-help@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.

Reply via email to