Creates or tests for objects of type
1 2 3
A non-negative integer specifying the desired length. Double values will be coerced to integer: supplying an argument of length other than one is an error.
object to be coerced or tested.
further arguments passed to or from other methods.
Integer vectors exist so that data can be passed to C or Fortran code which expects them, and so that (small) integer data can be represented exactly and compactly.
Note that current implementations of R use 32-bit integers for
integer vectors, so the range of representable integers is restricted
to about +/-2*10^9:
hold much larger integers exactly.
integer creates a integer vector of the specified length.
Each element of the vector is equal to
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.,
trunc(x) there), and
imaginary parts of complex numbers are discarded (with a warning).
Character strings containing optional whitespace followed by either a
decimal representation or a hexadecimal representation (starting with
0X) can be converted, as well as any allowed by
the platform for real numbers. Like
as.vector it strips
attributes including names. (To ensure that an object
x is of
integer type without stripping attributes, use
storage.mode(x) <- "integer".)
FALSE depending on
whether its argument is of integer type or not, unless it is a
factor when it returns
is.integer(x) does not test if
x contains integer
numbers! For that, use
round, as in the function
is.wholenumber(x) in the examples.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
floor on that help
page) to convert to integral values.
1 2 3 4 5 6 7 8 9 10 11
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.