Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
r
integer
communitycreator

What is the is.integer() function in R?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

In R, the is.integer() function is used to test if a given R object is of type integer or not.

Syntax

is.integer(x)
Syntax for the is.integer() function in R

Parameter

This function takes a single parameter value, x, representing any R object to be tested.

Return value

This function returns TRUE if the object is an integer. Otherwise, it returns FALSE.

Example

# creating R objects
my_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() function
is.integer(my_doubles1)
is.integer(my_doubles2)
is.integer(my_integers)
is.integer(my_random)
Implementing the is.integer() function

Explanation

  • Lines 2–5: We create different R objects containing numerical values.
  • Lines 9–12: We use the is.integer() function to check to see if each of the objects is an integer type or not.
Note: The object my_integers is the only integer type object among all of them. Interestingly, the object my_doubles2 is not an integer object but a double.

RELATED TAGS

function
r
integer
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring