c                    package:base                    R Documentation

_C_o_m_b_i_n_e _V_a_l_u_e_s _i_n_t_o _a _V_e_c_t_o_r _o_r _L_i_s_t

_D_e_s_c_r_i_p_t_i_o_n:

     This is a generic function which combines its arguments.

     The default method combines its arguments to form a vector. All
     arguments are coerced to a common type which is the type of the
     returned value, and all attributes except names are removed.

_U_s_a_g_e:

     c(..., recursive=FALSE)

_A_r_g_u_m_e_n_t_s:

     ...: objects to be concatenated.

recursive: logical.  If 'recursive = TRUE', the function recursively
          descends through lists (and pairlists) combining all their
          elements into a vector.

_D_e_t_a_i_l_s:

     The output type is determined from the highest type of the
     components in the hierarchy NULL < raw < logical < integer < real
     < complex < character < list < expression.  Pairlists are treated
     as lists, but non-vector components (such names and calls) are
     treated as one-element lists which cannot be unlisted even if
     'recursive = TRUE'.

     'c' is sometimes used for its side effect of removing attributes
     except names, for example to turn an array into a vector.
     'as.vector' is a more intuitive way to do this, but also drops
     names.  Note too that methods other than the default are not
     required to do this (and they will almost certainly preserve a
     class attribute).

_V_a_l_u_e:

     'NULL' or an expression or a vector of an appropriate mode. (With
     no arguments the value is 'NULL'.)

_S_4 _m_e_t_h_o_d_s:

     This function is S4 generic, but with argument list '(x, ...,
     recursive = FALSE)'.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'unlist' and 'as.vector' to produce attribute-free vectors.

_E_x_a_m_p_l_e_s:

     c(1,7:9)
     c(1:5, 10.5, "next")

     ## uses with a single argument to drop attributes
     x <- 1:4
     names(x) <- letters[1:4]
     x
     c(x)          # has names
     as.vector(x)  # no names
     dim(x) <- c(2,2)
     x
     c(x)
     as.vector(x)

     ## append to a list:
     ll <- list(A = 1, c="C")
     ## do *not* use
     c(ll, d = 1:3) # which is == c(ll, as.list(c(d=1:3))
     ## but rather
     c(ll, d = list(1:3))# c() combining two lists

     c(list(A=c(B=1)), recursive=TRUE)

     c(options(), recursive=TRUE)
     c(list(A=c(B=1,C=2), B=c(E=7)), recursive=TRUE)

