By Joseph Schmuller

Base R does not provide a function for finding the mode. A measure of central tendency, the mode, is important. It’s the score that occurs most frequently in a group of scores. Sometimes the mode is the best measure of central tendency to use.

Imagine a small company that consists of 30 consultants and two high-ranking officers. Each consultant has an annual salary of $40,000. Each officer has an annual salary of $250,000. The mean salary in this company is $53,125.

Does the mean give you a clear picture of the company’s salary structure? If you were looking for a job with that company, would the mean influence your expectations? You’re probably better off if you consider the mode, which in this case is $40,000 (unless you happen to be high-priced executive talent!).

Nothing is complicated about finding the mode. Look at the scores and find the one that occurs most frequently, and you’ve found the mode. Do two scores tie for that honor? In that case, your set of scores has two modes. (The technical name is bimodal.)

Can you have more than two modes? Absolutely.

If every score occurs equally often, you have no mode.

Base R does have a function called mode(), but it’s for something much different. Instead, you need a package called modeest in your library. (On the Packages tab, select Install, and then in the Install dialog box, type modeest in the Packages box and click Install. Then check its check box when it appears on the Packages tab.)

One function in the modeest package is called mfv() (“most frequent value”), and that’s the one you need. Here’s a vector with two modes (2 and 4):

> scores <- c(1,2,2,2,3,4,4,4,5,6)

> mfv(scores)

[1] 2 4