There is one more option that applies to both character and numeric data:
ux[which.max(tabulate(match(x, ux)))] mode - function(x) ux - unique(x) ux
That can produce a 10M-integer vector and determine its mode on my puny little PC in approximately 30 seconds.
The above method adopts the same strategy as which.max and delivers the first value of the set of modes if your data source is likely to have multiple modes. Use this variation (provided by @digEmAll in the comments) to return all modes:
Tabulate (match (x, ux)) ux[tab == max(tab)] Modes - function(x) - ux - unique(x)
}
Discover the world of data with our Data Science Course and embark on a transformative journey towards analytical excellence.