I am creating a logistic regression model using some data set. Despite removing factors containing only one level I am still getting the error:
> fit <- glm(Intraop_Blood_Products ~ ., family = binomial(), na.action = na.omit, data = rel_data)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
Although I cannot share the particular composition of the data. The function str(rel_data) shows that all factor variables contain two or more levels. Additionally, I tried using complete_case_data <- rel_data[complete.cases(rel_data),] to remove all NAs from the data set as another user suggested that glm() could be throwing this error due to the presence of NAs, yet the error persists. If you could offer any insight please let me know. Thank you!