本文介绍了图上的非字母字符箭头标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R软件包diagram一直在给我一些非常好的流程图.这是一个简单的示例:

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"))

我想将arrowlabel(当前设置为"hello")更改为(+)".所以,

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

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

但这失败了:

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

是否存在一组转义字符或其他技巧,将迫使parse将我的符号解释为简单文本?当然,一种解决方法是使用text在图上放置文本,但是我希望利用plotmat's内置标签定位功能.

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.

推荐答案

尝试

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

这篇关于图上的非字母字符箭头标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:21
查看更多