Reputation: 1039
I want to use the function bquote()
in R
to put a confidence interval on a graph. I am able to get the first parenthesis and number, but everything after that is problematic.
For example if I wanted to print the following confidence interval (2,5) then I have the following:
plot(1:5)
lower = 2
upper = 5
mtext(bquote("("~.(lower)))
that gets me half the interval but I can't get the rest of it. I would have thought something like
mtext(bquote("("~.(lower),","~.(upper),")")
would have worked, but it doesn't.
Upvotes: 1
Views: 449
Reputation: 32538
use as.expression
to coerce the whole thing into an expression and use *
to separate variables from strings
plot(1:5)
lower = 2
upper = 5
mtext(as.expression(bquote("("*.(lower)*","*.(upper)*")")))
Upvotes: 4