Check if an Object is an Expression in R Programming – is.expression() Function

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

Syntax: is.expression(object)

Parameters:
object: Object to be checked

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if
# an object is an expression
  
# Creating an object
x <- "sin(pi / 2)"
  
# Printing value of the object
eval(x)
  
# Calling is.expression() function
is.expression(x)

chevron_right


Output:

[1] "sin(pi/2)"
[1] FALSE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to check if
# an object is an expression
  
# Creating an object
x <- expression(sin(pi / 2))
  
# Printing value of the object
eval(x)
  
# Calling is.expression() function
is.expression(x)

chevron_right


Output:

[1] 1
[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.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.