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)
>>
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
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
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
4 matches
Mail list logo