Error when building regression model using lm ( Error in `contrasts<-`(`*tmp*`… contrasts can be applied only to factors with 2 or more levels) [duplicate]
问题 This question already has answers here : How to debug “contrasts can be applied only to factors with 2 or more levels” error? (2 answers) Closed last year . I get this error depending on which variables I include and the sequence in which I specify them in the formula: Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels I've done a little research on this and it looks like it would be caused by the variable in