fix warning vs. error for invalid level in a factor