Nick - 1 year ago 68

R Question

In R,

`mean()`

`median()`

`mode()`

Answer Source

One more solution, which works for both numeric & character/factor data:

```
Mode <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}
```

On my dinky little machine, that can generate & find the mode of a 10M-integer vector in about half a second.