On Jul 16, 2011, at 9:55 AM, Thomas Chesney wrote:
> I know there's a really easy way to do this but I just can't track
> it down. I experimented with various apply functions but couldn't
> get it quite right.
>
> I have a matrix like this:
>
> 1, 16
> 1, 23
> 1, 21
> 1, 6
> 1, 25
> 2, 4
> 2, 17
> 2, 45
> 2, 11
> 2, 20
tapply(mtx[,2], mtx[,1], max)>
> and I'd like to find the max value in Column 2 (or the index to the
> max value) grouped by the first column. So the max for Group 1, the
> max for Group 2 etc.
>
> Any help would be appreciated.
>
> ThomasThis message and any attachment are intended solely for the
> addressee and may contain confidential information. If you have
> received this message in error, please send it back to me, and
> immediately delete it. Please do not use, copy or disclose the
> information contained in this message or in any attachment. Any
> views or opinions expressed by the author of this email do not
> necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an
> attachment
> may still contain software viruses which could damage your computer
> system:
> you are advised to perform your own checks. Email communications
> with the
> University of Nottingham may be monitored as permitted by UK
> legislation.
> ______________________________________________
> R-help at r-project.org 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.
David Winsemius, MD
West Hartford, CT