Function: mode

This calculates the mode of a vector (like mean() and median()). Finds the most common element in a vector.

mode=function(vector_name)
{  as.numeric(names(sort(table(vector_name),decreasing=TRUE))[1])  }