On 09/06/08 17:24, Carlos Morales wrote: > Hello everyone, > > > I would like to know if there is any function to calculate the mode value, or > I have > to build one to do it.
I just did this the other day. Funny you should ask. It finds the mode of each row of a matrix called Pbest. Pbest.p <- apply(Pbest,1,function(x) x[which.max(as.vector(table(x)))][1]) So to get the mode of a vector v1, the following should work (but I haven't tried it): v1[which.max(as.vector(table(v1)))][1] -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron ______________________________________________ R-help@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.