On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu <vitosm...@rambler.ru> wrote: > On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham <h.wick...@gmail.com> > wrote: > > >>> or may be just >>> mtcars[cyl>3&last(20)] >>> >>> or this is already too far? >> >> This would be a considerable extension because then the selector would >> need to know about all other variables in the dataset, and you'd need >> someway of combining selectors with logical vectors. > > If selector returns a logical vector then I really don't see where is the > problem. Probably I am mistaken but implementing mtcars[cyl>3] is not such a > big deal. Just an operator `[.` start searching for "cyl" from inside the > "x" frame and not from parent.frame as it does now. It is just like putting > "with" inside '[', or not?
And that's a big change to the current behaviour! I think there are a few good reasons why this shouldn't be the default: * You could no longer do: cyl <- 4; mtcars[mtcars$cyl == cyl, ] (which is very useful when writing function) * If you want that behaviour, then just use subset * It only makes sense for variables of data frames, not for all the other types of subsets * Generally it's better to be explicit than not > When started with R I was really disappointed that such a natural and > intuitive subsetting is not allowed, but instead lengthy and ackward > mtcars[mtcars$syl>3] is required. > > R is an interactive language for 99% of the users and features like that(and > selectors indeed) would make a tremendous difference. > > Regards, > SV. > -- http://had.co.nz/ ______________________________________________ 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.