Search code examples
rexpressionplotmath

How to concatenate two expressions?


How can two expressions (expr and alpha~"is in ") be combined so that they are shown as one expression (in a plot label or via mtext() or so)?

expr <- expression(bgroup("(",frac(1,3)*", "*frac(1,2),")")) 
plot(0, 0, xlab = expression(c(alpha~"is in ", expr)), ylab = "") 

This seems to be related, but I didn't find it helpful for this particular question.


Solution

  • ... found an answer (thanks to a previous post which was deleted):

    expr <- bquote(bgroup("(",frac(1,3)*", "*frac(1,2),")")) 
    plot(0, 0, xlab = bquote(alpha~"is in "~.(expr)), ylab = "")