[R] Aggregating data

Gabor Grothendieck ggrothendieck at gmail.com
Wed Nov 29 20:24:30 CET 2006


Using the builtin data set CO2:

   aggregate(CO2[4:5], CO2[1], mean)

calculates the means of variables 4 and 5 based combinations of the
levels of variable 1.  Is that what you want?



On 11/29/06, David Kaplan <dkaplan at education.wisc.edu> wrote:
> Chuck and others.  Here is the problem I need help on.  Thanks.
>
> --------------------
>
> I want to follow-up on a question I had a week or so ago.  I want to
> aggregate a very large data set.  Generally in a program such as SPSS,
> one chooses a so-called "break variable" that is the variable, and then
> the remaining variables are aggregated by that variable with some
> summary statistic calculated - such as the mean.
>
> I played with "aggregate" in R and found that it requires a "by"
> statement listing the variables.  But I don't see how I can aggregate on
> one variable and create the summary statistics on the remaining
> variables.  I hope that was clear.  Thanks for an advice in advance.
>
> David
> ===========================================================================
> David Kaplan, Ph.D.
> Professor
> Department of Educational Psychology
> University of Wisconsin - Madison
> Educational Sciences, Room, 1061
> 1025 W. Johnson Street
> Madison, WI 53706
>
> email: dkaplan at education.wisc.edu
> homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
> Phone: 608-262-0836
> ===========================================================================
>
> Chuck Cleland wrote:
> > David Kaplan wrote:
> >> The problem is that this doesn't seem to give what I want.  I did look
> >> at this.  Perhaps doBy will work - haven't tried it yet.  But, any other
> >> suggestions are much appreciated.
> >
> > David:
> >   Your posts on aggregating came to the list without any text in the
> > body of the message (I believe Petr sent a response based only on the
> > subject).  You might get more specific and helpful suggestions if you
> > send a small example of what you are trying to do and why aggregate()
> > does not work for you.  Also, be sure to send messages in plain text
> > rather than HTML.
> >
> > hope this helps,
> >
> > Chuck Cleland
> >
> >> ===========================================================================
> >> David Kaplan, Ph.D.
> >> Professor
> >> Department of Educational Psychology
> >> University of Wisconsin - Madison
> >> Educational Sciences, Room, 1061
> >> 1025 W. Johnson Street
> >> Madison, WI 53706
> >>
> >> email: dkaplan at education.wisc.edu
> >> homepage: http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
> >> Phone: 608-262-0836
> >> ===========================================================================
> >>
> >> Petr Pikal wrote:
> >>> Similar answer as last time
> >>>
> >>> aggregate, tapply, by or ppackage doBy
> >>>
> >>> HTH
> >>>
> >>> PS. If you want to add some other text then subject in your post do
> >>> not use HTML posting as recommended in posting guide.
> >>>
> >>> Petr
> >>>
> >>>
> >>> On 28 Nov 2006 at 22:04, David Kaplan wrote:
> >>>
> >>> Date sent:          Tue, 28 Nov 2006 22:04:09 -0600
> >>> From:               David Kaplan <dkaplan at education.wisc.edu>
> >>> To:                 r-help at stat.math.ethz.ch
> >>> Subject:            [R] Aggregating data
> >>>
> >>>> ______________________________________________
> >>>> R-help at stat.math.ethz.ch mailing list
> >>>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>>> PLEASE do read the posting guide
> >>>> http://www.R-project.org/posting-guide.html and provide commented,
> >>>> minimal, self-contained, reproducible code.
> >>> Petr Pikal
> >>> petr.pikal at precheza.cz
> >>>
> >> ______________________________________________
> >> R-help at stat.math.ethz.ch mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list