1

How can I generate a title like this for sjp.grpfrq function?

enter image description here

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?

user2641103
  • 704
  • 9
  • 25

1 Answers1

0

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")
Daniel
  • 7,252
  • 6
  • 26
  • 38