From: Emmanuel Levy <emmanuel.levy_at_gmail.com>

Date: Wed 13 Sep 2006 - 16:38:17 GMT

R-help@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. Received on Thu Sep 14 02:46:59 2006

Date: Wed 13 Sep 2006 - 16:38:17 GMT

Thanks for pointing me out "aggregate", that works fine!

There is one complication though: I have mixed types (numerical and character),

A 1.0 200 ID1 A 3.0 800 ID1 A 2.0 200 ID1 B 0.5 20 ID2 B 0.9 50 ID2 C 5.0 70 ID1

One letter always has the same ID but one ID can be shared by many letters (like ID1)

I just want to keep track of the ID, and get a matrix like:

A 2.0 400 ID1 B 0.7 35 ID2 C 5.0 70 ID1

Any idea on how to do that without a loop?

Emmanuel

On 9/12/06, Emmanuel Levy <emmanuel.levy@gmail.com> wrote:

> Hello,

*>
**> I'd like to group the lines of a matrix so that:
**> A 1.0 200
**> A 3.0 800
**> A 2.0 200
**> B 0.5 20
**> B 0.9 50
**> C 5.0 70
**>
**> Would give:
**> A 2.0 400
**> B 0.7 35
**> C 5.0 70
**>
**> So all lines corresponding to a letter (level), become a single line
**> where all the values of each column are averaged.
**>
**> I've done that with a loop but it doesn't sound right (it is very
**> slow). I imagine there is a
**> sort of "apply" shortcut but I can't figure it out.
**>
**> Please note that it is not exactly a matrix I'm using, the function
**> "typeof" tells me it's a list, however I access to it like it was a
**> matrix.
**>
**> Could someone help me with the right function to use, a help topic or
**> a piece of code?
**>
**> Thanks,
**>
**> Emmanuel
**>
*

R-help@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. Received on Thu Sep 14 02:46:59 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Wed 13 Sep 2006 - 18:30:04 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*