How to debug “contrasts can be applied only to factors with 2 or more levels” error?

Introduction What a “contrasts error” is has been well explained: you have a factor that only has one level (or less). But in reality this simple fact can be easily obscured because the data that are actually used for model fitting can be very different from what you’ve passed in. This happens when you have … Read more