Check if the elements of a Vector are Finite, Infinite or NaN values in R Programming – is.finite(), is.infinite() and is.nan() Function
Last Updated :
04 Jun, 2020
is.finite()
function in R Language is used to check if the elements of a vector are Finite values or not. It returns a boolean value for all the elements of the vector.
Syntax: is.finite(x)
Parameters:
x: Vector to be checked
Example:
x < - c( 1 , 2 , 3 , 4 , 5 , NA, 6 , 7 )
is .finite(x)
|
Output:
[1] TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE
is.infinite() Function
is.infinite()
Function in R Language is used to check if the vector contains infinite values as elements. It returns a boolean value for all the elements of the vector.
Syntax: is.infinite(x)
Parameters:
x: Vector to be checked
Example:
x < - c( 1 , 2 , Inf, 4 , - Inf, 6 )
is .infinite(x)
|
Output:
[1] FALSE FALSE TRUE FALSE TRUE FALSE
is.nan() Function
is.nan()
Function in R Language is used to check if the vector contains any NaN(Not a Number) value as element. It returns a boolean value for all the elements of the vector.
Syntax: is.nan(x)
Parameters:
x: Vector to be checked
Example:
x < - c( 1 , 2 , - Inf, NaN, NaN, NaN)
is .nan(x)
|
Output:
[1] FALSE FALSE FALSE TRUE TRUE TRUE
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...