integer                 package:base                 R Documentation

_I_n_t_e_g_e_r _V_e_c_t_o_r_s

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

     Creates or tests for objects of type '"integer"'.

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

     integer(length = 0)
     as.integer(x, ...)
     is.integer(x)

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

  length: desired length.

       x: object to be coerced or tested.

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

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

     'integer' creates a integer vector of the specified length. Each
     element of the vector is equal to '0'. Integer vectors exist so
     that data can be passed to C or Fortran code which expects them.

     'as.integer' attempts to coerce its argument to be of integer
     type. The answer will be 'NA' unless the coercion succeeds. Real
     values larger in modulus than the largest integer are coerced to
     'NA' (unlike S which gives the most extreme integer of the same
     sign). Non-integral numeric values are truncated towards zero
     (i.e., 'as.integer(x)' equals 'trunc(x)' there), and imaginary
     parts of complex numbers are discarded (with a warning). Like
     'as.vector' it strips attributes including names.

     'is.integer' returns 'TRUE' or 'FALSE' depending on whether its
     argument is of integer type or not. 'is.integer' is generic: you
     can write methods to handle specific classes of objects, see
     InternalMethods. Note that factors are true for 'is.integer' but
     false for 'is.numeric'.

_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:

     'round' (and 'ceiling' and 'floor' on that help page) to convert
     to integral values.

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

       ## as.integer() truncates:
       x <- pi * c(-1:1,10)
       as.integer(x)

