prune.rpart              package:rpart              R Documentation

_C_o_s_t-_c_o_m_p_l_e_x_i_t_y _P_r_u_n_i_n_g _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:

     Determines a nested sequence of subtrees of the supplied 'rpart'
     object  by recursively 'snipping' off the least important splits,
     based on the  complexity parameter ('cp').

_U_s_a_g_e:

     prune(tree, ...)

     ## S3 method for class 'rpart':
     prune(tree, cp, ...)

_A_r_g_u_m_e_n_t_s:

    tree: 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.  

      cp: Complexity parameter to which the 'rpart' object will be
          trimmed. 

     ...: further arguments passed to or from other methods.

_V_a_l_u_e:

     A new 'rpart' object that is trimmed to the value 'cp'.

_S_e_e _A_l_s_o:

     'rpart'

_E_x_a_m_p_l_e_s:

     z.auto <- rpart(Mileage ~ Weight, car.test.frame)
     zp <- prune(z.auto, cp=0.1)
     plot(zp) #plot smaller rpart object

