0
myfun <- function(x){
  plot(x = 1, y = 1, main = expression(paste(delta, "title ", x)))
}

myfun(3)

I'm using paste to pass in the x variable for my plot title. However, because I also have a mathematical symbol, delta, in the mix, I'm using expression on top of paste. However, this causes the variable x to not appear in the plot title.

Edit:

plot(x = 1, y = 1, main = bquote(paste(delta, "title ", .(x)))) solves the problem!

However, the same approach did not work for boxplot(x = 1, y = 1, main = bquote(paste(delta, "title ", .(x)))).

5
  • 1
    Try using bquote and wrap in .( ) like this: plot(x = 1, y = 1, main = bquote(paste(delta, "title ", .(x)))) ... see this answer...or this one... Commented Jun 8, 2020 at 2:44
  • Thank you. I was wondering if there's a similar solution for boxplot instead of plot? I've edited the question. Commented Jun 8, 2020 at 2:50
  • 1
    boxplot(...) (no main), then add title(bquote(...)). Commented Jun 8, 2020 at 3:01
  • 1
    try splitting up the title as suggested here and by @r2evans Commented Jun 8, 2020 at 3:01
  • 1
    or just boxplot(1, 1, main = bquote(expression(paste(delta, " title ", .(x))))) Commented Jun 8, 2020 at 3:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.