Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

Here is my problem: for a plot label, I need to have a letter in square brackets ([M]) and a subscript right next to it. The normal way of making a subscript with expression function doesn't work:

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

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

expression(M[P])

it works.

Does anybody know how to overcome this? Thanks in advance!

like image 232
Andrey Dyachenko Avatar asked Jan 11 '13 15:01

Andrey Dyachenko


1 Answers

You can use

expression("[M]"[P])

An example:

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

enter image description here

like image 85
Sven Hohenstein Avatar answered Oct 20 '22 00:10

Sven Hohenstein