is.finite
Check IEEE Arithmetic Values

Description

Returns a logical vector, a matrix, or an array describing the type of numeric elements present. (This distinguishes between infinite values, NaNs, missing values, and ordinary numbers.)

Usage

is.finite(x) 
is.infinite(x) 
is.nan(x) 

Arguments

x a numeric vector, a matrix or an array.

Details

The values that are "Not a Number" are printed as NaN.
Value
returns an object containing logical values that is similar to the input. Values are FALSE for vectors that are not of mode "numeric".
is.finitedisplays TRUE for values of x that are specific non-infinite numbers (that is, not NA and not infinite).
is.infinitedisplays TRUE for values of x that are either plus or minus infinity.
is.nandisplays TRUE only for values that are "Not a Number". These are values created by an undefined numerical operation, such as 0/0 or Inf-Inf, and they are printed as NaN.
See Also
is.na, Arithmetic.
Examples
# 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) 

x <- matrix(c(1,2,3,4,NA, NaN, 7,8,Inf, -Inf, 11,12), nrow = 3) is.finite(x) is.nan(x)

Package base version 6.0.0-69
Package Index