Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
r
communitycreator

What is the is.numeric() 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.numeric() function returns a logical value, TRUE or FALSE, indicating if the argument passed to it has a base type of the class double or integer and the values are regarded as numeric.

Syntax

is.numeric(x)
Syntax for the is.numeric() function

Parameters

This function takes a single parameter value, x, which represents an R object to be tested.

Return value

This function returns TRUE if the argument is numeric and FALSE otherwise.

Example

# implementing the is.numeric() function
is.numeric(20)
is.numeric("twenty")
is.numeric(4.5)
Syntax for the is.numeric() function

Explanation

  • Line 2: We use the is.numeric() function on an argument, 20, to check if it is a numeric value or not. It returns true.
  • Line 3: We use the is.nuemric() function on an argument, "twenty", to check if it is a numeric value or not. It returns false.
  • Line 4: We use the is.numeric() function on an argument, 4.5, to check if it is a numeric value or not. It returns true.

RELATED TAGS

function
r
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