Re: [R] a max value for each column

From: TEMPL Matthias <Matthias.Templ_at_statistik.gv.at>
Date: Mon 17 Oct 2005 - 22:44:08 EST


apply(points, 2, max)
Should do the job.

For details look at ?apply

Best,
Matthias

>
> Dear R-list
>
> I have a dataset like below (points), how can I produce a max
> value for
> each column. I need a result like (I hope my eye correct):
>
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
> [1,] 21 1 10 99 14 19 6 9 5 8 5 7
>
> This is a small dataset from 10000 row.
> > points
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
> [1,] 21 0 9 16 1 11 5 2 5 8 2 5
> [2,] 19 1 10 93 7 0 0 4 1 6 5 1
> [3,] 13 0 4 30 5 7 1 1 5 6 3 6
> [4,] 5 1 9 61 6 19 2 9 5 1 1 6
> [5,] 2 1 1 99 1 18 1 3 2 8 1 2
> [6,] 7 0 5 45 14 4 6 5 1 6 5 6
> [7,] 0 0 6 89 14 3 2 0 3 7 2 6
> [8,] 15 0 1 30 14 17 3 2 3 3 3 5
> [9,] 14 0 5 28 8 10 1 6 5 2 3 6
> [10,] 12 1 4 65 6 2 4 1 4 4 4 7
> [11,] 14 1 1 3 12 10 5 7 4 3 3 4
> [12,] 15 0 1 55 7 7 1 5 3 7 0 2
> [13,] 14 0 5 4 7 11 2 0 4 2 2 3
> [14,] 13 0 6 94 6 2 4 9 3 4 0 3
> [15,] 21 1 5 79 14 14 6 3 5 6 5 6
> >
>
> ______________________________________________
> 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
>



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 Received on Mon Oct 17 22:49:44 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:59:24 EST