Check if an Object is of Type Integer in R Programming – is.integer() Function
is.integer()
function in R Language is used to check if the object passed to it as argument is of integer type.
Syntax: is.integer(x)
Parameters:
x: Object to be checked
Example 1:
# R program to check if # object is an integer # Creating a vector x1 < - 4L x2 < - c( 1 : 6 ) x3 < - c( "a" , "b" , "c" , "d" ) x4 < - c( 1 , 2 , "a" , 3 , "b" ) # Calling is.integer() function is .integer(x1) is .integer(x2) is .integer(x3) is .integer(x4) |
Output:
[1] TRUE [1] TRUE [1] FALSE [1] FALSE
Example 2:
# R program to check if # object is an integer # Creating a matrix x1 < - matrix(c( 1 : 9 ), 3 , 3 ) # Calling is.integer() function is .integer(x1) |
Output:
[1] TRUE
Please Login to comment...