R, rpart(), classification tree, cptable$xerror i randomly split my data into training and test sets.
then using the training set, i construct an overfitting classification tree with 10-fold cross-validation. i.e. 

xval=10

and prune it (with prune.rpart()) according to the 

cptable$CP

that corresponds to

min(cptable$xerror)

then i predict classes for the test set using the pruned tree and find that the fraction of misclassified test cases is almost less than 

min(cptable$xerror)/7

this is peculiar because the 

min(cptable$xerror)

is about 7 times larger, than the misclssification error rate on the test set, whereas i think they should be approximately equal
i've repeated the above procedure multiple times and gotten very similar results. (xerror=0.2, test misclassification error=0.03 approximately)
multiple repetitions of the same procedure on another data, the difference was of factor 3 (xerror=0.6, test misclassification error=0.2 approximately)
this leads me to suspect that, when constructing classification trees using rpart(), 

cptable$xerror

does not give the cross-validated misclassification error rate that i expect (i.e. ratio of misclassifications to total classification attempts) but rather some other quantification of misclassifications. but i couldn't find anything in the documentation. or i could be making a silly mistake somewhere .... 
here's the gist of my script for one of the data sets:
(datt is the data.frame, the response is NSP (column 25), and column 24 is irrelevant here so it is excluded in both training and testing)
# split into training/test sets
test.i<-sample(seq(1:dim(datt)[1]),floor(dim(datt)[1]/10))
ctg.train<-datt[-test.i,]
ctg.test<-datt[test.i,]

t.cont<-rpart.control(minsplit=0,cp=0.00000001,xval=10)
ctree<-rpart(NSP~.,data=ctg.train[,-24],control=t.cont,method='class')

best.cp<-ctree$cptable[which.min(ctree$cptable[,'xerror']),'CP']
pruned.ctree<-prune.rpart(ctree,cp=best.cp)
min(ctree$cptable[,'xerror']) # ** approx. 0.2**
p.tree<-predict(pruned.ctree,ctg.test[,-c(24,25)],type='class')
tab<-table(p.tree,ctg.test[,25]) # confusion matrix
(sum(tab)-sum(diag(tab)))/sum(tab) # ** approx 0.03**

would appreciate it if someone could shed some light on this. thanks!
EDIT: think i got it, xerror is just the sum of the Gini index for all the nodes right?
 A: Decision tree classifiers (DTC) can be tricky when you apply CV to them.  In point of fact, I commonly don't employ CV for DTC and Random Forests (RF).  Here's why: A DTC algorithm is a distant relative of RF, and since RFs bootstrap the entire data set without CV and randomly draw the features used for finding optimal node-splitting thresholds, they nevertheless use the entire dataset during a run.  (When sampling with replacement to construct a bootstrap dataset, on average, 37% of the objects won't be selected and these are assigned to the out-of-bag "OOB" test sample, while the 63% of objects in the bootstrapped "in-bag" sample are used for training).  Thus, RF does its own CV via use of what was (was not) selected without replacement.  Further, a DTC is an algorithm for which you want to show the reader, audience, (manager), that when using all of the samples and informative features, these are the threshold feature cut-values that separate the majority of classes into final child nodes that have class purity.  
Now, if you perform CV with a DTC, a reader can ask: "So, based on the CV you performed, what is the final cutpoint of each feature that will allow me to make decision rules?" The problem is when creating your response, you realize the cutpoints changed every time a different set of training folds was used, because the feature values change with the training folds used.  Now you think, well, maybe show a histogram of the cutpoints for each feature that was identified over all the CVs.  But if you wanted to do this, you would just employ RF, which can provide importance scores for features, outliers, and can generalize better.
A DTC can be more meaningful when all objects are used for a single run, using all informative features.  If you want to start modifying DTCs with CV, it would be better to use RFs, for which everything already exists.  
