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.
In LaTeX text mode, the vertical bar produces an em dash(—). The \textbar command can be used to produce a vertical bar.
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.”
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 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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With