Function that obtains a statistic of centrality of a
variable, given a sample of values.
If the variable is numeric it returns de median, if it
is a factor it returns the mode. In other cases it
tries to convert to a factor and then returns the mode.
Taken from:
https://github.com/ltorgo/DMwR2/