[R] request: a class having max frequency

Jim Lemon jim at bitwrit.com.au
Sat Jun 7 13:38:27 CEST 2008


Muhammad Azam wrote:
> Dear R users
> I have a very basic question. I tried but could not find the  required  result. using
> dat <- pima
> f <- table(dat[,9])
> 
> 
>>f 
> 
>   0   1 
> 500 268
> i want to find that class say "0" having maximum frequency i.e 500. I used
> 
>>which.max(f)
> 
> which provide 
> 0 
> 1  
> How can i get only the "0".  Thanks and 
> 
The "Mode" function in the prettyR package does this.

Jim



More information about the R-help mailing list