On 04/04/2013 09:56 AM, Peter Ehlers wrote:
On 2013-04-03 14:59, Sarah Goslee wrote:
Of course it can. Use the mode() in the same way you used the mean()
function.

You didn't provide a reproducible example, so I can't provided tested
code, but I would think that you can add
mode=mode(COUNTS) to the ddply() arguments.

?mode will direct you to the help page for _storage_ mode of an object.
That's not likely what the OP had in mind. It seems that what s/he
wants is the "most frequent value". This is (usually) a pretty useless
piece of information, but there are a number of packages that do
provide it.

To the OP:
Install package sos and then do findFn("mode") to see what's available.
E.g. packages, pracma, asbio, dprep, rattle and many others.
Do note that they handle the multimodal situation differently.

Or, write your own, perhaps using table() and which.max().

The OP might find the Mode (note capital M) function (prettyR) helpful.

Jim

______________________________________________
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.

Reply via email to