[R] Finding Values that Occur Most Often in a Vector
Duncan Mackay
mackay at northnet.com.au
Thu Jul 10 08:58:42 CEST 2008
If you just want the value which is the most frequent try
as.numeric(names(which.max(table(c( -295.8045 ,-295.8045, -295.8045,
-295.8045 ,-325.4754 ,-295.8045, -295.8045, -295.8045, -413.2099,
-295.8045)))))
[1] -295.8045
There may be easier ways
Regards
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email:
home: mackay at northnet.com.au
At 16:04 10/07/2008, you wrote:
>Hi,
>
>Is there a way to do it?
>
>For example I have the following vector:
>
> > print(myvector)
> > [1] -295.8045 -295.8045 -295.8045 -295.8045 -325.4754 -295.8045 -295.8045
> [8] -295.8045 -413.2099 -295.8045
>
>I want it to return -295.8045, which occur most often.
>
>- Gundala Viswanath
>Jakarta - Indonesia
>
>______________________________________________
>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.
More information about the R-help
mailing list