Question: how is error calculated rpart?
Answer: sum(tb) gives the total number of instances. sum(diag(tb)) gives the instances with correct predictions. by taking the ratio you are calculating the accuracy and by subtracting from one , you are getting the error rate. ... By taking sum of all the cases in matrix, you get the total number of instances.