Non alpha character arrowlabels on a diagram

心已入冬 提交于 2020-01-04 14:39:08

问题


The R package diagram has been giving me some very nice flow charts. Here is a simple example:

install.packages("diagram")
require(diagram)
A = matrix(nrow = 2, ncol = 2, data = 0)
A[2,1] = "hello"
par(xpd = NA)
plotmat(A, name = c("A", "B"))

I would like to change the arrowlabel (currently set as "hello") to be "(+)". So,

A[2,1] = "(+)"
plotmat(A, name = c("A", "B"))

But this fails:

Error in parse(text = x, ...) : <text>:1:3: unexpected ')'
1: (+)
     ^

Is there a set of escape characters, or some other trick, that will force parse to interpret my symbols as simple text? Of course, a workaround is to use text to place text on the plot, but I'm hoping to take advantage of plotmat's built-in label positioning functionality.


回答1:


Try

A[2,1] = "`(+)`"
plotmat(A, name = c("A", "B"))



来源:https://stackoverflow.com/questions/24632243/non-alpha-character-arrowlabels-on-a-diagram

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!