This is the line with the error:
predicted <-predict(fit, test_data
)
This is the code for testing the model for predicting the income
The error that I got was:
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : factor education has new levels 10th, 11th, 12th, 1st-4th, 5th-6th, 7th-8th, 9th, Assoc-acdm, Assoc-voc, Bachelors, Doctorate, HS-grad, Masters, Preschool, Prof-school, Some-college
str(df)
for your training model and thetest_data
. – Todd Burus