Looks like there might have been some truncation of Jonathon Baron's message.
Here's one way of computing the sample mode of a vector.
> set.seed(1) > x <- sample(1:5,20,rep=T) > x [1] 2 2 3 5 2 5 5 4 4 1 2 1 4 2 4 3 4 5 2 4 > table(x) x 1 2 3 4 5 2 6 2 6 4 > names(which.max(table(x))) [1] "2" >
Note that this method returns the first max value in the case of ties.
hope this helps,
Tony Plate
At Tuesday 11:01 AM 8/24/2004, Jonathan Baron wrote:
On 08/24/04 13:50, Paolo Tommasini wrote: >Hi my name is Paolo Tommasini does anyone know how to compute a "mode" >( most frequent element ) for a distribution ?
which.max
-- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R search page: http://finzi.psych.upenn.edu/
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html