Re: [R] request: which integer in each column is in majority

2008-05-28 Thread Karl Ove Hufthammer
Muhammad Azam: > I am one of the new R user. I have a problem regarding to know which of > the integer in each column of the following matrix is in majority. I want > to know that integer e.g. in the first column 1 is in majority. > >> x=matrix(c(1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4,1,2,3,3),ncol=4) >>

Re: [R] request: which integer in each column is in majority

2008-05-28 Thread Uwe Ligges
Muhammad Azam wrote: Respected R helpers/ users I am one of the new R user. I have a problem regarding to know which of the integer in each column of the following matrix is in majority. I want to know that integer e.g. in the first column 1 is in majority. Similarly in the third column 4 is

Re: [R] request: which integer in each column is in majority

2008-05-28 Thread jim holtman
try this: > x [,1] [,2] [,3] [,4] [1,]1234 [2,]1241 [3,]1342 [4,]2343 [5,]2343 > apply(x, 2, function(.col)dimnames(table(.col))[[1]][which.max(table(.col))]) [1] "1" "3" "4" "3" > On Wed, May 28, 2008 at 5:23 A

[R] request: which integer in each column is in majority

2008-05-28 Thread Muhammad Azam
Respected R helpers/ users I am one of the new R user. I have a problem regarding to know which of the integer in each column of the following matrix is in majority. I want to know that integer e.g. in the first column 1 is in majority. Similarly in the third column 4 is in majority. So what is