Check if an Object is an Expression in R Programming - is.expression() Function
Last Updated :
24 Jun, 2020
Improve
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 checkedExample 1:
# 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)
[1] "sin(pi/2)" [1] FALSEExample 2:
# 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)
[1] 1 [1] TRUE