At the end of a ggplot, this works fine:
+ opts(title = expression("Chart chart_title..."))
But this does not:
chart_title = "foo"
+ opts(title = expression(chart_title))
nor this:
chart_title = "foo"
+ opts(title = chart_title)
How can I add a title to a ggplot when the title is a variable name?
Opts is being deprecated. One option is to use labs()
myTitle <- "My title"
qplot(mpg, wt, data = mtcars) + labs(title = myTitle)
Pretty much the same.