snip.rpart               package:rpart               R Documentation

_S_n_i_p _S_u_b_t_r_e_e_s _o_f _a_n _R_p_a_r_t _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Creates a "snipped" rpart object, containing the nodes that remain
     after selected subtrees have been snipped off.  The user can snip
     nodes using the toss arguement, or interactively by clicking the
     mouse button on specified nodes within the graphics window.

_U_s_a_g_e:

     snip.rpart(x, toss)

_A_r_g_u_m_e_n_t_s:

       x: fitted model object of class 'rpart'.  This is assumed to be
          the result of some function that produces an object with the
          same named components as that returned by the 'rpart'
          function. 

    toss: an integer vector containing indices (node numbers) of all
          subtrees to be snipped off.  If missing, user selects
          branches to snip off as described below. 

_D_e_t_a_i_l_s:

     A dendrogram of 'rpart' is expected to be visible on the graphics
     device, and a graphics input device (e.g., a mouse) is required. 
     Clicking (the selection button) on a node displays the node
     number, sample size, response yvalue, and Error (dev). Clicking a
     second time on the same node snips that subtree off and visually
     erases the subtree. This process may be repeated an number of
     times.  Warnings result from selecting the root or leaf nodes. 
     Clicking the exit button will stop the snipping process and return
     the resulting 'rpart' object.

     See the documentation for the specific graphics device for details
     on graphical input techniques.

_V_a_l_u_e:

     a 'rpart' object containing the nodes that remain after specified
     or selected subtrees have been snipped off.

_W_a_r_n_i_n_g:

     Visually erasing the plot is done by over-plotting with the
     background colour.  This will do nothing if the background is
     transparent (often true for screen devices).

_S_e_e _A_l_s_o:

     'plot.rpart'

_E_x_a_m_p_l_e_s:

     ## dataset not in R
     ## Not run: 
     z.survey <- rpart(market.survey) #grow the rpart object
     plot(z.survey) #plot the tree
     z.survey2 <- snip.rpart(z.survey,toss=2) #trim subtree at node 2
     plot(z.survey2) #plot new tree

     # can also interactively select the node using the mouse in the
     # graphics window
     ## End(Not run)

