Benoît Lété wrote: > Hello, > > I have an elementary question (for which I couldn't find the answer on the > web or the help): how can I extract the mode (modal score) of a vector?
Assuming that your vector contains only integers: > v <- sample(1:5, size=20, replace=T) > v [1] 1 1 1 1 2 3 5 1 1 5 2 4 1 3 1 1 5 4 1 5 > vt <- table(v) > as.numeric(names(vt[vt == max(vt)])) [1] 1 > Cheers, Gad -- Gad Abraham Department of Mathematics and Statistics The University of Melbourne Parkville 3010, Victoria, Australia email: [EMAIL PROTECTED] web: http://www.ms.unimelb.edu.au/~gabraham ______________________________________________ [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 and provide commented, minimal, self-contained, reproducible code.
