Added 2 functions for handling factor and numeric NA values.