How to view the resulting tree using the bagging function in R?

I constructed a tree with the `rpart` function. Then I can plot it to look at the tree visually and also look at what % of the observations were classified correctly using `table(predict(...), ...)`.

mytree=rpart(y~x1+x2+x3+x4, method="class")
      table(predict(mytree, t="class"), status)
And that last line would output something like this:
         0   1
      0 165  48
      1  17  52
Then I proceed to use the `bagging`function in the ipred package.
     my.bagging=bagging(y~x1+x2+x3+x4, data=mydata)
I tried:
But I couldn't generate a tree visually. How can I see the picture of the actual tree? Also, how can I see what % was classified correctly with this new tree (like how I used `table(predict(...),...)` with the tree I constructed using `rpart`. I would like to know how the predictive power of `my.bagging` tree compares to that of `mytree`. Any help will be greatly appreciated.
As far as I know, Bagging Tree is a predictive tool, so you won't be able to see an average tree.

I think you can look at each generated tree using $mtrees.


Will show you the first bootstrapped tree.

I think that when you call the bagging function you should enter the number of bootstrapped replications using the nbagg parameter. I don't know which is the default parameter, so I don't know how many trees did it use.


Phineas Packard
Yep. I am not sure plotting the tree makes any sense here in the context of bagging, random forest or boosting. You should be able to plot variable importance if you like.