Check if an Object is of Type Numeric in R Programming – is.numeric() Function

is.numeric() function in R Language is used to check if the object passed to it as argument is of numeric type.

Syntax: is.numeric(x)

Parameters:
x: Object to be checked

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if 
# object is of numeric type
  
# Calling is.numeric() function
is.numeric(1)
is.numeric(1.5)
is.numeric(-1.5)

chevron_right


Output:

[1] TRUE
[1] TRUE
[1] TRUE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if 
# object is of numeric type
  
# Creating a matrix
x1 <- matrix(c(1:9), 3, 3)
  
# Calling is.numeric() function
is.numeric(x1)

chevron_right


Output:

[1] TRUE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.