The expression()
function in R creates an expression from the arguments passed to it.
expression(x)
The expression()
function takes one parameter value x
. This represents an R object, such as a call, symbol, or constant.
The expression()
function returns a vector of the type expression
. This contains its arguments.
# Creating an expression using the expression() functionmyexpression <- expression(1 + 2)# Obtaining the result of the expression using the eval() functioneval(myexpression)# Checking the class of the objectclass(myexpression)
myexpression
using the expression()
function.eval()
function, and print its result.myexpression
using the class()
function.