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:
# R program to check if# an object is an expression # Creating an objectx <- "sin(pi / 2)" # Printing value of the objecteval(x) # Calling is.expression() functionis.expression(x) |
Output:
[1] "sin(pi/2)" [1] FALSE
Example 2:
# R program to check if# an object is an expression # Creating an objectx <- expression(sin(pi / 2)) # Printing value of the objecteval(x) # Calling is.expression() functionis.expression(x) |
Output:
[1] 1 [1] TRUE


