smartbind               package:gtools               R Documentation

_E_f_f_i_c_i_e_n_t _r_b_i_n_d _o_f _d_a_t_a _f_r_a_m_e_s_y, _e_v_e_n _i_f _t_h_e _c_o_l_u_m_n _n_a_m_e_s _d_o_n'_t _m_a_t_c_h

_D_e_s_c_r_i_p_t_i_o_n:

     Efficient rbind of data frames, even if the column names don't
     match

_U_s_a_g_e:

     smartbind(...)

_A_r_g_u_m_e_n_t_s:

     ...: Data frames to combine

_V_a_l_u_e:

     The returned data frame will contain: 

 columns: all columns present in any provided data frame

    rows: a set of rows from each provided data frame, with values in
          columns not present in the given data frame filled with
          missing ('NA') values.

     The data type of columns will be preserved, as long as all data
     frames with a given column name agree on the data type of that
     column.  If the data frames disagree, the column will be converted
     into a character strings.  The user will need to coerce such
     character columns into an appropriate type.

_A_u_t_h_o_r(_s):

     Gregory R. Warnes warnes@bst.rochester.edu

_S_e_e _A_l_s_o:

     'rbind', 'cbind'

_E_x_a_m_p_l_e_s:

       df1 <- data.frame(A=1:10, B=LETTERS[1:10], C=rnorm(10) )
       df2 <- data.frame(A=11:20, D=rnorm(10), E=letters[1:10] )

       # rbind would fail
     ## Not run: 
       rbind(df1, df2)
       # Error in match.names(clabs, names(xi)) : names do not match previous
       # names:
       #     D, E
     ## End(Not run)
       # but smartbind combines them, appropriately creating NA entries
       smartbind(df1, df2)

