Check if an Object is of Type Integer in R Programming - is.integer() Function
Last Updated :
16 Jun, 2020
Improve
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 checkedExample 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)
[1] TRUE [1] TRUE [1] FALSE [1] FALSEExample 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)
[1] TRUE