表达式+变量值+正式文本在绘图主题 [英] expression + variable value + normal text in plot maintitle
问题描述
我想在R情节中获得标题如下:
title =您输入的意义级别是alpha = 0.05,经常使用。
为了得到这个我将整个文本分成几部分,所以我终于可以写
title = paste(part1,part2,part3,part4)
部分是:
part1 =您输入的意义级别
part2 =表达式(alpha)
part3 = object @属性
part4 =经常使用。
所以我无法组合这些部分来获得我的结果。符号被正确显示,第3部分被打印为对象@属性(蚂蚁不是他的值),或者不显示符号,并且对象的值是打印正确。
我已经使用了?表达式
和?print
但没有得到它
?plotmath
中提供的示例与我的案例也不匹配。
一个解决方案是使用 bquote()
。在 bquote
中使用。()
来获取对象或表达式的值。以下是一个例子:
obj = list(foo = 0,bar = 99,alpha = 0.05)
plot(1:10,main = bquote(Significance level is〜alpha ==。(obj $ alpha)))
波纹符号〜
似乎需要说服 bquote
将alpha视为
i want to achieve an title in R plot as the following:
title = "The significance level you entered is alpha = 0.05 which is often used."
In order to get this I split the whole text in little parts, so i finally can write
title = paste(part1,part2,part3,part4)
The parts are:
part1 = "The significance level you entered is"
part2 = expression(alpha)
part3 = object@attribute
part4 = " which is often used."
So I'm not able to combine these parts to get my result.
Either the symbol is shown correctly and the part 3 is printed as object@attribute (ant not his value) or the symbol is not shown and the value of the object is printed correctly.
I used ?expression
and ?print
already, but didn't get it
The examples provided in ?plotmath
didn't match my case either.
One solution is to use bquote()
. Use .()
within bquote
to get the value of objects or expressions. Here is one example of how that might work:
obj = list(foo=0, bar=99, alpha=0.05)
plot(1:10, main=bquote("Significance level is" ~ alpha == .(obj$alpha)))
The tilde ~
seems necessary here to convince bquote
to treat alpha as a plotmath expression.
这篇关于表达式+变量值+正式文本在绘图主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!