is.finite(x) is.infinite(x) is.inf(x) is.nan(x) is.number(x)
"numeric"
.
is.finite
is
TRUE
for values of
x
that are
specific non-infinite numbers (that is, not
NA
and not infinite).
is.infinite
is
TRUE
for values of
x
that are either
plus or minus infinity.
is.inf
is an abbreviation for
is.infinite
is.nan
is only
TRUE
for values that are "Not a Number". These are
values that were created by an undefined numerical operation, such as
0/0
or
Inf-Inf
and they are printed as
NA
.
is.number
is
TRUE
if the value is finite or infinite, i.e., is
neither missing (
NA
) nor not-a-number (
NaN
).
In previous versions of S-PLUS, values that were "Not a Number" were
printed as
NaN
; they are now printed as
NA
.
The
is.nan
(and
which.nan
) function is the only way to distinguish
between values that are "Not a Number" and values that are truly missing.
These functions are useful only on machines that support the IEEE arithmetic standard (the VAX is not such a machine). Spotfire S+ arithmetic and some of its mathematical functions conform to the standard.
# a non-zero number divided by zero creates infinity # zero over zero creates a NaN weird.values <- c(1/0, -20.9/0, 0/0, NA) is.infinite(weird.values) is.nan(weird.values) is.na(weird.values)