If $\int_A f \mathrm d \mu \in F$ for every measurable set $A$, then $f$ takes values on $F$ almost surely Let $(X, \mathcal F, \mu)$ be a $\sigma$-finite measure space and $(E, |\cdot|)$ a Banach space. Here we use the Bochner integral. Let $f:X \to E$ be $\mu$-integrable and $F$ a non-empty subset of $E$.

Statement: If
$$
\int_A f \mathrm d \mu \in F \quad \forall A \in \mathcal F,
$$
then there is a $\mu$-null set $N \in \mathcal F$ such that $f(x) \in F$ for all $x \in N^c := X \setminus N$.

I encountered this problem in defining the conditional expectation, i.e., I already construct it for $\mathbb C^n$-valued random vectors and would like to get back the one for $\mathbb R^n$-valued random vectors.
Could you elaborate if this statement is true and how to prove it?
Update: If necessarily, I can impose either $\mu$ is a probability measure, $F$ is convex, or $F$ is closed.
 A: In the comments to your question, a reference is given to Rudin's Real and Complex Analysis.  Since you are asking about the Bochner integral, while Rudin and most textbook treatments of integration focus on real and complex-valued integrals, you'd probably prefer a reference that addresses the question in the context of the Bochner integral. See Theorem 5.15 in Lang's Real and Functional Analysis (3rd ed.). Here is the statement there, with a few edits I explain after the theorem.
Theorem.  Let $f \in L^1(\mu,E)$ and $S$ be a closed subset of $E$ such that
$$
\frac{1}{\mu(A)}\int_A f\,{\rm d}\mu \in S
$$
for all measurable $A \subset X$ with finite positive measure and either $0 \in S$ or $X$ is $\sigma$-finite. Then $f(x) \in S$ for $\mu$-almost all $x \in X$.
Lang actually starts the theorem with "$f \in \mathscr L^1(\mu,E)$", where $\mathscr L^1(\mu,E)$ is defined on the bottom of p. $128$, and such functions might not be measurable initially. At the start of section IV on p. $134$ he notes such $f$ can be taken to be measurable by adjusting them on a set of measure $0$, and on p. 139 he notes $L^1(\mu,E)$ is the quotient space of $\mathscr L^1(\mu,E)$ modulo the subspace of functions that vanish almost everywhere.
Lang left out the conditions that $0 \in S$ or $X$ is $\sigma$-finite, but a counterexample without at least one of these conditions is the following.
Let $X = \{a,b\}$ be a two-point space and $\mu$ be the measure on $X$ with $\mu(a) = 1$ and $\mu(b) = \infty$, so $(X,\mu)$ is not $\sigma$-finite. Let $E = \mathbf R$ and
$f \colon X \to E$ where $f(a) \not= 0$ and $f(b) = 0$. Set $S = \{f(a)\}$, so $f \in L^1(\mu,E)$ and $S$ is closed in $E$, but $0 \not\in S$. The integration hypothesis in the theorem is satisfied, but it's not true that $f(x) \in S$ for $\mu$-almost all $x \in X$, as $f(b) \not\in S$ and $\mu(\{b\}) = \infty$.
