Reputation: 77
Previous questions on subscripts in R (specifically relating to text in ggplot/annotate/geo arguments) don't quite touch on this issue.
Say I want to have a subscript "+", like
$\Sigma_+$
If I do something like
scale_colour_manual(values = c('red' = 'red','blue' = 'blue'),name = '',
labels = expression(P[+] - P[-] == P[w])
We get an error similar to:
Error: unexpected ']' in:
"scale_colour_manual(values = c('red' = 'red','blue' = 'blue'),name = '',
labels = expression(P[+]"
Upvotes: 1
Views: 160
Reputation: 77
I think that R thinks that the + is acting as a arithematic operator, and adding two non-numbers "[" and "]".
The solution is to put make the subscript a character string. I think that some people may forget that this is a possibility.
scale_colour_manual(values = c('red' = 'red','blue' = 'blue'),name = '',
labels = expression(P["+"] - P["-"] == P[w])
Upvotes: 1