I am pretty new to R, so apologies in advance if this is a simple question.
I have made a Decision Tree classification model using the rpart package.
This works fine and I have used it to predict the variable in my test data. I am trying to make a confusion matrix table to compare the results but I keep getting the following error:
Error in table(EmployeeTest$Leaver, pred) :
all arguments must have the same length
I have looked online and can't seem to find the solution.
The code I am using to create the matrix is as follows:
table_mat <- table(EmployeeTest$Leaver,pred)
pred is the predicted results of the model and looks like this:
summary(pred)
pred
Leaver :61
Non-Leaver:91
The Employee Test table contains over 100 variables but the field I am interested in looks like:
summary(EmployeeTest$Leaver)
Leaver Non-Leaver
66 86
Any help would really be appreciated as I have no idea how to fix this. I know the error suggests it is to do with length but both tables contains the same variables with the same lengths.
Thanks in advance.