# This function calculates the mode in R. Mode <- function(x) { ux <- unique(x) ux[which.max(tabulate(match(x, ux)))] }