is.infinite return a vector of the same
x, indicating which elements are finite (not infinite
and not missing) or infinite.
-Inf are positive and negative infinity
NaN means ‘Not a Number’. (These apply to numeric
values and real and imaginary parts of complex values but not to
values of integer vectors.)
reserved words in the R language.
is.finite(x) is.infinite(x) is.nan(x) Inf NaN
R object to be tested: the default methods handle atomic vectors.
is.finite returns a vector of the same length as
jth element of which is
x[j] is finite (i.e., it
is not one of the values
FALSE otherwise. Complex
numbers are finite if both the real and imaginary parts are.
is.infinite returns a vector of the same length as
jth element of which is
x[j] is infinite (i.e.,
equal to one of
otherwise. This will be false unless
x is numeric or complex.
Complex numbers are infinite if either the real or the imaginary part is.
is.nan tests if a numeric value is
NaN. Do not test
NaN, or even use
systems typically have many different NaN values. One of these is
used for the numeric missing value
false for that value. A complex number is regarded as
either the real or imaginary part is
NaN but not
All elements of logical, integer and raw vectors are considered not to
All three functions accept
NULL as input and return a length
zero result. The default methods accept character and raw vectors, and
FALSE for all entries. Prior to R version 2.14.0 they
accepted all input, returning
FALSE for most non-numeric
values; cases which are not atomic vectors are now signalled as
All three functions are generic: you can write methods to handle specific classes of objects, see InternalMethods.
A logical vector of the same length as
names attributes are preserved.
In R, basically all mathematical functions (including basic
Arithmetic), are supposed to work properly with
+/- Inf and
NaN as input or output.
The basic rule should be that calls and relations with
really are statements with a proper mathematical limit.
NaN will return
NaN or perhaps
NA: which of those two is not guaranteed and may depend
on the R platform (since compilers may re-order computations).
The IEC 60559 standard, also known as the ANSI/IEEE 754 Floating-Point Standard.
D. Goldberg (1991).
What Every Computer Scientist Should Know about Floating-Point
ACM Computing Surveys, 23(1), 5–48.
Also available at https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html.
The C99 function
isfinite is used for
NA, ‘Not Available’ which is not a number
as well, however usually used for missing values and applies to many
modes, not just numeric and complex.
pi / 0 ## = Inf a non-zero number divided by zero creates infinity 0 / 0 ## = NaN 1/0 + 1/0 # Inf 1/0 - 1/0 # NaN stopifnot( 1/0 == Inf, 1/Inf == 0 ) sin(Inf) cos(Inf) tan(Inf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.