R-Studio - Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

Welcome to community!

Could you update your title so that it is more descriptive and informative? From our Writing r coding questions guide;

Write now it reads like you are suggesting there is an issue with how RStudio runs a regression. I'd suggest summarizing what you are doing and the error you get.


Also, with a question like this, it's polite to pose your questions as a reproducible example, or reprex for short. (FAQ: What's a reproducible example (`reprex`) and how do I create one? I'd particularly like to see a minimal snippet of data that produces this error). That'll make it much easier to help diagnose the issue here.