Reputation: 7517
In the R code below, (seems strange to me) I'm wondering WHY the subscript in 'CT'[01]
used in the legend()
, ZERO doesn't show, BUT when I use 'CT'[10]
ZERO correctly shows?
Here is the R code:
plot(1:10,ty="n")
## This one below, `0` doesn't show in the `CT[01]` !!!!! ##
legend("topright", legend=bquote(paste("Evidence favors A ",bold(('CT'[01]))," = ", .(round(1/Gi,3)))),
pch = "",cex=2, bty="n", inset=c(.0,-.12))
## But this one below `0` shows correctly in the `CT[10]` Ok Ok OK ##
legend("topright", legend=bquote(paste("Evidence favors A ",bold(('CT'[10]))," = ", .(round(1/Gi,3)))),
pch = "",cex=2, bty="n", inset=c(.0,-.12))
Upvotes: 1
Views: 163
Reputation: 7457
I think the WHY is as follows: The function bold()
evaluates the expression with the subscript. Therefore it evaluates the value inside the []
-brackets. Default is to interpret it as a number. This makes totally sense: Think of a subscript [i]
that is evaluated in a for loop. This will do the "right" number to every plot.
Therefore the 01 will be plotted as 1 and the 10 as 10.
So if you wish to print out the 0 in front of the 1 use 'CT'[0][1]
or 'CT'['01']
. The first one displays two numbers 0 and 1, the second one is evaluated as character and therefore the 0 will not be omitted.
Upvotes: 1