math | Mathematics‎ > ‎math | R‎ > ‎

math.r | Eval

http://stackoverflow.com/questions/1743698/r-eval-expression

eval() evaluates an expression, but "5+5" is a string, not an expression. So, use parse() with text= to translate the string to an expression:

> eval(parse(text="5+5"))
[1] 10
> class("5+5")
[1] "character"
> class(parse(text="5+5"))
[1] "expression"

Comments