How to put square brackets and index next to each other in expression R?

Here is my problem: for the graph label, I need to have a letter in square brackets ([M]) and a subscript next to it. The usual way to create an index with an expression function does not work:

expression(paste("[M]",[P])) 

returns an error - apparently, she wants to have something in front of the index, because this way -

 expression(M[P]) 

it works.

Does anyone know how to overcome this? Thank you in advance!

+5
source share
1 answer

you can use

 expression("[M]"[P]) 

Example:

 plot(1, main = expression("[M]"[P])) 

enter image description here

+5
source

All Articles