thanks a lot for your help, the error is gone by following your tip.
but i have another question , after i wrote this code i got another error, i know i got this error because i have missing values in my data. but the point is i want to evaluate the performance of the classifier with and without NAs. so any help please to run the confusion matrix while having NAs.
p<- predict(mymodel1, train)
table(p, train$Air.Quality)
Error in table(p, train$Air.Quality) :
all arguments must have the same length
length(train$Air.Quality)
[1] 4020
length(p)
[1] 1998