Search code examples
rexpressionquartz-graphicsfractions

Variables inside an frac (expression) in R


I am trying to write an expression in R which needs to have a fraction as well. I need to include a variable that's defined somewhere else in the program inside the frac() function in R expression.

N <- 20
text(100,2,expression((5-alpha) ~ where ~ alpha == frac(2, 1 +N)))

But I am unable to get the value of N inside the frac function to output 20. How to go about doing this?


Solution

  • If you want the actual value of variable N substituted, use substitute() command.