Hi all
I recently Googled to find out how to get the mode from my continuous
data in R, and came up with this ancient thread from the archives:
http://tolstoy.newcastle.edu.au/R/help/99b/1319.html
But sorting is very inefficient if you have lots of data, so can I
propose this method:
h <- hist(x, breaks=512)
mode <- h$mids[h$counts == max(h$counts)]
of course, breaks can be whatever is sensible for your data, which you
can check by running
plot(h)
Apologies if this is ridiculously obvious,
Michael
--
Dr Michael Doube BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London SW7 2AZ
United Kingdom
______________________________________________
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.