How do I use two variables in title of a plot in R?

graphics, latex, plot, r

Solution

You can use `substitute` instead of `expression`. The second argument is a list specifying replacement strings and objects.

a <- 5
b <- 1
plot(1, 1, main = substitute(paste(p == a, ", ", q == b), list(a = a, b = b)))

Problem

How do I use variables in Latex expressions in R? For example: `a<-5; b<-1; plot(X, Y, main=expression(paste(p==a,q==b)))` `a` and `b` are R variables. Also I want to have "," in Output? How do I do that?

Original source