I am trying to run a MANOVA and run into the error:
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
I am aware that this occurs when a variable only has 1 level, or has multiple levels but only values for 1 of those levels. I have two variables that give this error, however, their table results are:
$varA
No Yes
81 314
$varB
No Yes
35 363
The issue occurs after recoding one level of both of these variables. The cell counts were too low (5 and 2 respectively), due to which I have recoded them as NA. I then drop the unused level:
df$varA[df$varA=="unusableLevel"] <- NA
df$varB[df$varB=="unusableLevel"] <- NA
df <- droplevels(df)
Both variables are correctly specified as factors. I have tried using different methods for recoding the unusable level to NA. I have been scratching my head at this for a while. Unfortunately I cannot produce a minimal reproducible example as I am not allowed to share any of the data in any form.
Thanks for any help!