Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

displaying multiple inequality symbols using expression()

Tags:

r

I have encountered difficulty trying to display multiple inequality symbols in a text box placed on a plot window in R. Using a single inequality is acceptable, such as mtext(expression("a">="b")). However, using three inequalities, such as mtext(expression("a">="b and c"<"d"<="e")) leads to halting of execution by the interpreter, which complains that the second inequality symbol is unexpected. How can multiple inequalities be used within a single text box?

like image 504
user001 Avatar asked Feb 14 '14 08:02

user001


People also ask

What are the 5 inequality symbols?

The five inequality symbols in Maths are greater than symbol (>), less than symbol (<), greater than or equal to symbol (≥), less than or equal to symbol (≤), and not equal to symbol (≠).

How do I print greater than or equal to in r?

The Less Than or Equal To, and Greater Than or Equal To Operators <= and >= We can also check to see if one R object is greater than or equal to (or less than or equal to) another R object. To do this, we can use the less than sign, or the greater than sign, together with the equals sign.


2 Answers

You can also do this by mixing plotmath symbol and paste:

mtext(expression(a>b ~and ~paste(c < d) <= e))

enter image description here

like image 156
agstudy Avatar answered Sep 30 '22 18:09

agstudy


You can use phantom() for a non-visible symbol:

plot(1)
mtext(expression(a >= b ~ and ~ c < d ~ phantom() <= e)) 

enter image description here

like image 33
Sven Hohenstein Avatar answered Sep 30 '22 17:09

Sven Hohenstein