2

I'm wondering how I can replace the multiplication sign (i.e., x) with its ASCII code (Alt 0215) in my current text() code in R below?

NOTE: If you know of any code other than ASCII for the multiplication sign (i.e., x) that is compatible with Shiny that would be OK.

Here is my R code:

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 Answers1

2

Try this:

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)

For type <- 1 here is the result:

screenshot

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341