[R] The end of Matlab

hadley wickham h.wickham at gmail.com
Fri Dec 12 23:14:13 CET 2008


On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu <vitosmail at rambler.ru> wrote:
> On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham <h.wickham at 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/



More information about the R-help mailing list