Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Gabor Grothendieck
And here is one more approach using the reshape package: library(reshape) dataset.d <- melt(dataset, id = 1:2) cast(dataset.d, gp1 + gp2 ~ variable, mean) On 9/30/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Check out summaryBy in the doBy package at: > > http://genetics.agrsci.dk/~sor

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Duncan Murdoch
On 9/30/2005 1:41 PM, hadley wickham wrote: > I'm not entirely sure what you want, but maybe this does the trick? > > data.frame.by <- function(data, variables, fun, ...) { > if (length(variables) == 0 ) { > df <- data.frame(results = 0) > df$results <- list(fun(d

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Duncan Murdoch
On 9/30/2005 1:41 PM, Peter Dalgaard wrote: > Duncan Murdoch <[EMAIL PROTECTED]> writes: > >> I want to calculate a statistic on a number of subgroups of a dataframe, >> then put the results into a dataframe. (What SAS PROC MEANS does, I >> think, though it's been years since I used it.) >> >>

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Marc Schwartz (via MN)
On Fri, 2005-09-30 at 13:22 -0400, Duncan Murdoch wrote: > I want to calculate a statistic on a number of subgroups of a dataframe, > then put the results into a dataframe. (What SAS PROC MEANS does, I > think, though it's been years since I used it.) > > This is possible using by(), but it see

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Gabor Grothendieck
Check out summaryBy in the doBy package at: http://genetics.agrsci.dk/~sorenh/misc e.g. summaryBy(value ~ gp1 + gp2, data = dataset) On 9/30/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > I want to calculate a statistic on a number of subgroups of a dataframe, > then put the results in

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread Peter Dalgaard
Duncan Murdoch <[EMAIL PROTECTED]> writes: > I want to calculate a statistic on a number of subgroups of a dataframe, > then put the results into a dataframe. (What SAS PROC MEANS does, I > think, though it's been years since I used it.) > > This is possible using by(), but it seems cumbersome

Re: [Rd] by() processing on a dataframe

2005-09-30 Thread hadley wickham
I'm not entirely sure what you want, but maybe this does the trick? data.frame.by <- function(data, variables, fun, ...) { if (length(variables) == 0 ) { df <- data.frame(results = 0) df$results <- list(fun(data$value, ...)) return(df)