var2fct function

Convert vector to factor based on threshold of number of unique levels