Convert an argument to an integer
asInteger
is intended to be used for vectors while asInt
is
a specialization for scalar integers and asCount
for scalar
non-negative integers.
Convertible are (a) atomic vectors with all elements NA
and (b) double vectors with all elements being within tol
range of an integer.
Note that these functions may be deprecated in the future.
Instead, it is advised to use assertCount
,
assertInt
or assertIntegerish
with
argument coerce
set to TRUE
instead.
asInteger( x, tol = sqrt(.Machine$double.eps), lower = -Inf, upper = Inf, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, .var.name = vname(x) ) asCount( x, na.ok = FALSE, positive = FALSE, tol = sqrt(.Machine$double.eps), .var.name = vname(x) ) asInt( x, na.ok = FALSE, lower = -Inf, upper = Inf, tol = sqrt(.Machine$double.eps), .var.name = vname(x) )
x |
[any] |
tol |
[ |
lower |
[ |
upper |
[ |
any.missing |
[ |
all.missing |
[ |
len |
[ |
min.len |
[ |
max.len |
[ |
unique |
[ |
sorted |
[ |
names |
[ |
.var.name |
[ |
na.ok |
[ |
positive |
[ |
This function does not distinguish between
NA
, NA_integer_
, NA_real_
, NA_complex_
NA_character_
and NaN
.
Converted x
.
asInteger(c(1, 2, 3)) asCount(1) asInt(1)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.