cbind                  package:base                  R Documentation

_C_o_m_b_i_n_e _C_o_l_u_m_n_s/_R_o_w_s _i_n_t_o _a _M_a_t_r_i_x

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

     Take a sequence of vector and/or matrix arguments and combine them
     as the columns or rows, respectively, of a matrix.

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

     cbind(...)
     rbind(...)

_D_e_t_a_i_l_s:

     The functions `cbind' and `rbind' are generic, with methods for
     data frames.

     If there are several matrix arguments, they must all have the same
     number of columns (or rows) and this will be the number of columns
     (or rows) of the result.  If all the arguments are vectors, the
     number of columns (rows) in the result is equal to the length of
     the longest vector.  Values in shorter arguments are recycled to
     achieve this length (with a `warning' when they are recycled only
     fractionally).

     When the arguments consist of a mix of matrices and vectors the
     number of columns (rosw) of the result is determined by the number
     of columns (rows) of the matrix arguments.  Any vectors have their
     values recycled or subsetted to achieve this length.

_N_o_t_e:

     The method dispatching is not done via `UseMethod(..)', but by
     C-internal dispatching. Therefore, there's no need for, e.g.,
     `rbind.default'.

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

     `c' to combine vectors (and lists).

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

     cbind(1,1:7) # the '1' (= shorter vector) is recycled
     cbind(1:7, diag(3))# vector is subset -> warning

     cbind(0,rbind(1,1:3))

     cbind(0, matrix(1, nrow=0, ncol=4))#> Warning (making sense)
     dim(cbind(0, matrix(1, nrow=2, ncol=0)))#-> 2 x 1

