In R, the is.integer()
function is used to test if a given R object is of type integer or not.
is.integer(x)
This function takes a single parameter value, x
, representing any R object to be tested.
This function returns TRUE
if the object is an integer. Otherwise, it returns FALSE
.
# creating R objectsmy_doubles1 <- c(1.1 , 2.2 , 3.3, 4.4 )my_doubles2 <- c(1 , 2 , 3 , 4 )my_integers <- c(1L , 2L , 3L , 4L )my_random <- c(1L , 2L , 3L , 4 )#implementing the is.integer() functionis.integer(my_doubles1)is.integer(my_doubles2)is.integer(my_integers)is.integer(my_random)
is.integer()
function to check to see if each of the objects is an integer
type or not.Note: The objectmy_integers
is the only integer type object among all of them. Interestingly, the objectmy_doubles2
is not an integer object but a double.