[R] The end of Matlab
hadley wickham
h.wickham at gmail.com
Fri Dec 12 18:27:02 CET 2008
On Fri, Dec 12, 2008 at 11:11 AM, Vitalie Spinu <vitosmail at rambler.ru> wrote:
> On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham <h.wickham at gmail.com>
> wrote:
>
>> You could also imagine similar iterators for random sampling, like
>> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
>> with replacement. first(n) could also be useful, selecting the first
>> min(n, length(vector)) observations. An iterator version of rev()
>> would also be handy.
>>
>> Maybe selector would be a better name than iterator though, as these
>> don't have the same feel as iterators in other languages.
>
> That is really something!! Real high level language!!
> "Selectors" could depend on named variables in data frame as well:
>
> mtcars[sel(cyl>3)&last(5)]
> mtcars[sel(cyl>3)&boot(80%)]
>
> 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. So it would be a
huge increase in complexity for not much gain, given that with just
the interface we have described you could do:
mtcars[mtcars$cyl > 3, ][last(20), ]
# or
subset(mtcars, cyl > 3)[last(20), ]
The main idea of selectors is that they would be independent of the
data structure that they are being used with.
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list