Convert an Expression to a String in R Programming – deparse() Function
Last Updated :
24 Jun, 2020
deparse()
function in R Language is used to convert an object of expression class to an object of character class.
Syntax: deparse(expr)
Parameters:
expr: Object of expression class
Example 1:
x < - expression(sin(pi / 2 ))
class (x)
x1 < - deparse(x)
class (x1)
|
Output:
[1] "expression"
[1] "character"
Example 2:
x < - expression( 2 ^ 3 )
eval (x)
x1 < - deparse(x)
eval (x1)
|
Output:
[1] 8
[1] "expression(2^3)"
Share your thoughts in the comments
Please Login to comment...