Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add vertical bar in expression to plot

Tags:

r

expression

I'd like to add an expression to a plot, in which a conditional term appears, such as E(Y|X). Using for example:

plot(x=c(.5),ylim=c(0,1),xlim=c(0,2))
text(x=1,y=.5,labels=expression(E(X|Y)),pos=1)

does not do it, but it produces E(|(X,Y)). Obviously I do not know how to get the vertical bar into the expression properly - can somebody help? Thanks.

like image 751
tomka Avatar asked Mar 20 '13 17:03

tomka


People also ask

How do I make vertical bars in LaTeX?

In LaTeX text mode, the vertical bar produces an em dash(—). The \textbar command can be used to produce a vertical bar.

What does a vertical line in an equation mean?

The most common way to represent the absolute value of a number or expression is to surround it with the absolute value symbol: two vertical straight lines. |6| = 6 means “the absolute value of 6 is 6.” |–6| = 6 means “the absolute value of –6 is 6.” |–2 – x| means “the absolute value of the expression –2 minus x.”

What does vertical bar do in Python?

In many programming languages, the vertical bar is used to designate the logic operation or, either bitwise or or logical or.

What is the vertical slash called?

What is the vertical bar ( | )? The vertical bar ( | ) -- also called the vertical line, vertical slash, pipe, pipe symbol or upright slash -- is a symbol used in mathematics, computing and other areas to represent a specific type of logic or operation, depending on its context.


1 Answers

plot(x=c(.5),ylim=c(0,1),xlim=c(0,2))
expr = expression("E" * (X ~ "|" ~ Y))
text(x=1,y=.5,labels=expr,pos=1,cex=4)

EDIT

@joran proposes a different version ( there are less spaces in this one)

 expr1 = expression(E(X*"|"*Y))
 text(x=1,y=.8,labels=expr2,pos=1,cex=4)

enter image description here

like image 134
agstudy Avatar answered Sep 21 '22 01:09

agstudy