Conditional expectation $E(X | XI'm stuck calculating the following expectation:

Given a (discrete) RV $X$ with $P(X=0)=P(X=1)=P(X=2)=1/3$ and $Y \sim \text{Unif}(0,2)$ what is $E(X | X<Y)$?

Now what I did was conditioning on $Y$, i.e.
\begin{align}
E(X | X<Y)
&=\int_0^2\frac{1}{2}E(X | X<y)dy \\
&=\int_0^1\frac{1}{2}E(X | X<y)dy+\int_1^2\frac{1}{2}E(X | X<y)dy \\
&=\frac{1}{2}\cdot 0 + \frac{1}{2} \cdot 1=\frac{1}{2}.
\end{align}
To confirm this I simulated the situation with R. I simulated an instance of $X$ and $Y$ 10,000 times and if $X < Y$ I remembered $X$. However the mean of this list was $\frac{1}{3}$ and not $\frac{1}{2}$ as expected.
Can someone tell me what I did wrong? Thanks!
 A: The answer is $1/3$.  Given that $X<Y$, there are three possible situations, depending on the value of $X$, but they're not all equally likely:
$X=0, Y>0$ (probability $2/3$); $X=1,Y>1$ (probability $1/3$), and $X=2,Y>2$ (probability $0$).  Thus $E[X | X<Y] = 0(2/3) + 1(1/3) + 2(0) = 1/3$.
A: Another way to look at the problem (and to check your result)  is to approach from this angle: $$E(X|X<Y)=\sum_{i=0}^2 i \cdot P(X=i \ | \ Y>X)$$
and $$P(Y>X) = \sum_{i=0}^2 P(Y > X \ | \ X=i) \cdot P(X=i) $$
I took advantage of this approach and determined that the expected value is in fact $\frac{1}{3}$
A: We have $$\mathbb{E}\left[X\mid X<Y\right]=\frac{1}{2}\intop_{0<y<2}\mathbb{E}\left[X\mid X<y\right]dy=\frac{1}{2}\intop_{0<y<2}\frac{\mathbb{E}\left[X\mathtt{1}_{\left\{ X<y\right\} }\right]}{\mathbb{P}\left[X<y\right]}dy
 $$ $$=\frac{1}{2}\intop_{0<y<2}\frac{1}{\mathbb{P}\left[X<y\right]}\intop_{x\in\mathbb{R}}x1_{\left\{ x<y\right\} }\left(x,y\right)\frac{1}{3}\left(\delta_{0}\left(x\right)+\delta_{1}\left(x\right)+\delta_{2}\left(x\right)\right)dy$$$$=\frac{1}{6}\intop_{0<y<2}\frac{1}{\mathbb{P}\left[X<y\right]}\intop_{x\in\mathbb{R}}x1_{\left\{ x<y\right\} }\left(x,y\right)\delta_{1}\left(x\right)dy
 $$ $$=\frac{1}{6}\intop_{0<y<2}\frac{1}{\mathbb{P}\left[X<y\right]}1_{\left\{ 1<y\right\} }\left(y\right)dy=\frac{1}{6}\intop_{1<y<2}\frac{1}{\mathbb{P}\left[X<y\right]}dy.
 $$ Now, when $1<y<2
 $, we have $\mathbb{P}\left[X<y\right]=\mathbb{P}\left[X=0\right]+\mathbb{P}\left[X=1\right]=2/3
 $ and thus$$\mathbb{E}\left[X\mid X<Y\right]=\frac{1}{6}\intop_{1<y<2}\frac{1}{2/3}dy=\frac{1}{4}.
 $$This result does not match with your experimental one, so I am a bit dubious... The better is to wait for another answer.
EDIT: The above result was not correct because the first equality is false. Using the definition of a discrete conditional expectation leads to the correct answer as it has been well done in the other answers.
