Re: [Rd] split.data.frame

2009-12-17 Thread Matthew Dowle
This seems very similar to the data.table package. The 'by' argument splits the data.table by that value then executes the j expression within each subset. The package documentation talks about 'subset' and 'with' in some detail. See ?"[.data.table". dt = data.table(x=1:20, y=rep(1:4,each=5)

Re: [Rd] split.data.frame

2009-12-15 Thread Romain Francois
On 12/16/2009 12:14 AM, Peter Dalgaard wrote: Romain Francois wrote: Hello, I very much enjoy "with" and "subset" semantics for data frames and was wondering if we could have something similar with split, basically by evaluating the second argument "with" the data frame : I seem to recall tha

Re: [Rd] split.data.frame

2009-12-15 Thread Peter Dalgaard
Romain Francois wrote: Hello, I very much enjoy "with" and "subset" semantics for data frames and was wondering if we could have something similar with split, basically by evaluating the second argument "with" the data frame : I seem to recall that this idea was considered and rejected when

Re: [Rd] split.data.frame

2009-12-15 Thread Felix Andrews
I agree, I would definitely appreciate that. A simpler implementation: split.data.frame <- function(x, f, drop = FALSE, ...) { ff <- eval(substitute(f), x, parent.frame()) lapply(split(seq_len(nrow(x)), ff, drop = drop, ...), function(ind) x[ind, , drop = FALSE]) } df <- data.frame(x =

[Rd] split.data.frame

2009-12-15 Thread Romain Francois
Hello, I very much enjoy "with" and "subset" semantics for data frames and was wondering if we could have something similar with split, basically by evaluating the second argument "with" the data frame : split.data.frame function(x, f, drop = FALSE, ...){ call <- match.call( )