How can I generate a title like this for sjp.grpfrq function?
As example, I can generate a text like that with:
plot.new()
a <- TeX(sprintf("%s (%s, $N_{HIGH}$=%d/$N_{TOTAL}$=%d)", "Whatever", "Blah", 10, 20))
text(0.5,0.5,a)
But I cannot use something like this:
sjp.grpfrq(age.group, var.group, showValueLabels = FALSE, title = a)
Because I get the following error:
Error in title == "" : comparison is not allowed for expressions
So, how can I generate a title that have subscripts expressions in it?
You could try to add the title afterwards. The function call returns a list with a $plot
object, where you can add a title with ggtitle
:
library(sjPlot)
library(ggplot2)
library(sjmisc)
data(efc)
sjp.grpfrq(efc$e42dep, efc$e16sex)$plot + ggtitle("New Title")