Related Articles

Related Articles

Create an Expression in R Programming – expression() Function
  • Last Updated : 24 Jun, 2020

expression() function in R Language is used to create an expression from the values passed as argument. It creates an object of the expression class.

Syntax: expression(character)

Parameters:
character: Expression, like calls, symbols, constants

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to create an expression
  
# Calling expression() Function
x <- expression(2 ^ 3)
x
  
# Printing value of the expression
eval(x)

chevron_right


Output:

expression(2^3)
[1] 8

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to create an expression
  
# Calling expression() Function
x <- expression(sin(pi / 2))
x
  
# Printing value of the expression
eval(x)
  
# Printing class of expression
class(x)

chevron_right


Output:

expression(sin(pi/2))
[1] 1
[1] "expression"
My Personal Notes arrow_drop_up
Recommended Articles
Page :