我想在ggplot中添加以下标题:
"Number of times where UK emissions of Sulphur Dioxide exceeded 10 microgrammes per metre cubed"
此标题的组件来自:
free text = "Number of times where UK emissions of "
input$select = Sulphur Dioxide (or any other pollutant the user selects)
free text = "exceeded "
input$number = 10 (or any other integer the user selects)
formula = μg/m3 (where the 3 is superscript of m)
使用了粘贴和表达和引用的组合,但它只是不对。
这是我上面的代码....
ggplot() +
aes(x=year, y=cnt) +
labs(title = paste("Number of times where UK emissions of ", input$select,
" exceeded", input$number, expression(mu), "g/m", "^{3}"))
我不确定你在问什么,但如果你将"u03BCg/mu00B3"
用于μg/m³
部分,它会很好地打印。
或者如果你想使用正确的plotmath表达式,它看起来像这样
library(ggplot2)
ggplot(mtcars) +
aes(x=mpg, y=disp) +
labs(title = bquote("Number of times where UK emissions of "~.(input$select)~
" exceeded"~.(input$number)~mu*g/m^3))