用R

时间:2017-03-11 17:56:43

标签: r function plot shiny ascii

我想知道如何在我当前的Alt 0215代码中用ASCII代码(text()替换乘法符号(即x)下面?

注意:如果您知道除了ASCII之外的任何代码,那么与Shiny兼容的乘法符号(即x)就可以了。

这是我的R代码:

G1 = 1 
G2 = 2
type = 1

plot(1:10, ty = "n", ann = F, bty = "n")

text(6, 6,
 bquote(paste("GG = ", frac(.(G1), .(G2)),
              .(ifelse(type == 1, " × 2", "")), ## HERE is where I need to use the ASCII code for "×"
              " = ", 
              .(ifelse(type == 1, G1/G2 * 2, G1/G2)), sep = "")),
 col = "red4", cex = 1.6)

1 个答案:

答案 0 :(得分:0)

试试这个:

plot(1:10, ty = "n", ann = F, bty = "n")
b <- if (type == 1) {
       bquote({GG == frac(.(G1), .(G2)) * " \u00D7 2"} == .(2 * G1/G2))
} else bquote({GG == frac(.(G1), .(G2))} == .(G1/G2))
text(6, 6, b, col = "red4", cex = 1.6)

对于type <- 1,结果如下:

screenshot