adrop                 package:abind                 R Documentation

_D_r_o_p _d_i_m_e_n_s_i_o_n_s _o_f _a_n _a_r_r_a_y _o_b_j_e_c_t

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

     Drop degenerate dimensions of an array object.  Offers more
     control than the 'drop()' function.

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

     adrop(x, drop = TRUE, named.vector = TRUE, one.d.array = FALSE)

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

       x: An array (including a matrix) 

    drop: A logical or numeric vector describing the dimensions to be
          dropped. 

named.vector: (Optional, defaults to 'TRUE'.  Controls whether a vector
          result has names derived from the 'dimnames' of 'x'.

one.d.array: (Optional, defaults to 'FALSE'.  If 'TRUE', a
          one-dimensional array result will be an object with a 'dim'
          attribute of length 1, and possibly a 'dimnames' attribute. 
          If 'FALSE', a one-dimensional result will be a vector object
          (named if 'named.vector==TRUE').

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

     Dimensions can only be dropped if their extent is one, i.e.,
     dimension 'i' of array 'x' can be dropped only if 'dim(x)[i]==1'.
     It is an error to request 'adrop' to drop a dimension whose extent
     is not 1.

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

     If 'x' is an object with a 'dim' attribute (e.g., a matrix or
     'array'), then 'adrop' returns an object like 'x', but with the
     requested extents of length one removed.  Any accompanying
     'dimnames' attribute is adjusted and returned with 'x'.

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

     Tony Plate tplate@acm.org

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

     'abind'

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

     x <- array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26]))
     adrop(x[1,,,drop=FALSE],drop=1)
     adrop(x[,1,,drop=FALSE],drop=2)
     adrop(x[,,1,drop=FALSE],drop=3)
     adrop(x[1,1,1,drop=FALSE],drop=1)
     adrop(x[1,1,1,drop=FALSE],drop=2)
     adrop(x[1,1,1,drop=FALSE],drop=3)
     adrop(x[1,1,1,drop=FALSE],drop=1:2)
     adrop(x[1,1,1,drop=FALSE],drop=1:2,one.d=TRUE)
     adrop(x[1,1,1,drop=FALSE],drop=1:2,named=FALSE)
     dim(adrop(x[1,1,1,drop=FALSE],drop=1:2,one.d=TRUE))
     dimnames(adrop(x[1,1,1,drop=FALSE],drop=1:2,one.d=TRUE))
     names(adrop(x[1,1,1,drop=FALSE],drop=1:2,one.d=TRUE))
     dim(adrop(x[1,1,1,drop=FALSE],drop=1:2))
     dimnames(adrop(x[1,1,1,drop=FALSE],drop=1:2))
     names(adrop(x[1,1,1,drop=FALSE],drop=1:2))

