is.finite and is.infinite return a vector of the same length as x, indicating which elements are finite (not infinite and not missing) or infinite. Inf and -Inf are positive and negative infinity whereas 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.) Inf and NaN are reserved words in the R language.
is.finite(x)
is.infinite(x)
is.nan(x)<p></p><p>Inf
NaN</p>
| Parameter | Description |
|---|---|
x |
R object to be tested: the default methods handle atomic vectors. |
# NOT RUN {
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)
# }