[R] Matrix max by row

jim holtman jholtman at gmail.com
Sun Mar 29 01:26:25 CET 2009


?apply

> x <- rbind(c(2,5,3),c(8,7,2),c(1,8,4))
> apply(x, 1, max)
[1] 5 8 8
>
>


On Sat, Mar 28, 2009 at 7:54 PM, Ana M Aparicio Carrasco
<ana.aparicio at upr.edu> wrote:
> I need help about how to obtain the max by row in a matrix.
> For example if I have the following matrix:
> 2 5 3
> 8 7 2
> 1 8 4
>
> The max by row will be:
> 5
> 8
> 8
>
> Thank you.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list