本文介绍了在R的小图中加下划线文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在下图中标出平均值:
I am trying to underline the mean value in the following plot:
dummy <- c(4, 9, 6, 5, 3)
barplot(dummy)
text(4, 8,paste('Average value', mean(dummy)))
我尝试使用underline()
,但是它说找不到该功能.
I tried using underline()
but it says it could not find the function.
text(4, 8,paste('Average value', underline(mean(dummy))))
错误:
could not find function "underline"
我正在使用:R版本3.1.0
I am using : R version 3.1.0
推荐答案
像这样:
text(4, 8, bquote("Average value"~underline(.(mean(dummy)))))
或者如果您希望整个文本都带有下划线:
or if you want the whole text underlined:
text(4, 8, bquote(underline("Average value"~.(mean(dummy)))))
请注意使用bquote
和.(x)
在表达式中插入变量的值.
Note use of bquote
and .(x)
to insert the value of a variable in the expression.
这篇关于在R的小图中加下划线文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!