Let $(X,Z)$ be a real-valued and $\mathbb R^n$-valued pair of random variables, so that $X:\Omega\to\mathbb R$ and $Z:\Omega\to\mathbb R^n$. Suppose $(X,Z)$ has joint density $f_{X,Z}$ with respect to $\mathcal L^{n+1}$, let $f_Z$ be the marginal density of $Z$, and suppose $X\in L^1(\Omega,\mathcal F,\mathbb P)$. Using the measurable joint density, define the conditional mean by taking the positive and negative part integrals and subtracting them where both are finite:
\begin{align*}
g:\mathbb R^n&\to\mathbb R \\
z&\mapsto
\begin{cases}
\int_{\mathbb R} x\, f_{X\mid Z}(x\mid z)\,d\mathcal L^1(x), & f_Z(z)>0 \text{ and the integral is finite},\\
0, & \text{otherwise}.
\end{cases}
\end{align*}
If the defining integral is finite for $f_Z(z)\,d\mathcal L^n(z)$-a.e. $z$, then $g(Z)\in L^1(\Omega,\mathcal F,\mathbb P)$ and
\begin{align*}
\mathbb E[X\mid Z]=g(Z)
\end{align*}
$\mathbb P$-a.s.