The library statement should have been library(doBy). Also note
that collapse assumes that all by variables are factors although
it would only add one statement to collapse to coerce them to
factors if we wanted that.
On 10/13/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> As far as I know y
As far as I know you will have to do some work yourself but
if we leverage some of it off the summaryBy function in doBy
its basically just a lapply over the columns.
The first arg to collapse is a formula whose rhs contains the
by variables and whose lhs is ignored. data is our data frame,
fac.f
> > Here's a solution that takes the first element of each factor
> > and the mean of each numeric variable. I can imagine there
> > are more general/flexible solutions. (One might want to
> > specify more than one summary function, or specify that
> > factors that vary within group should be d
On 10/12/07, Ben Bolker <[EMAIL PROTECTED]> wrote:
>
>Trying to find a quick/slick/easily interpretable way to
> collapse a data set.
>
> Suppose I have a data set that looks like this:
>
> h <- structure(list(INDEX = structure(1:6, .Label = c("1", "2", "3",
> "4", "5", "6"), class = "factor"
> On 10/12/07, Ben Bolker ufl.edu> wrote:
> >
> > Trying to find a quick/slick/easily interpretable way to
> > collapse a data set.
> >
Another alternative for SQL fans is the sqldf package. I used the MySQL driver
here since SQLite does not support standard deviation.
sqldf("select BROOD,
Here is one way. Not sure what you wanted done with some of the other
variables, so I just chose the first one; you could do max/min:
> z <- by(h, h$BROOD, function(x){
+ # take first value of elements you don't want to change
+ data.frame(BROOD=x$BROOD[1], TICKS.mean=mean(x$TICKS),
TICKS
6 matches
Mail list logo