  A measurement of inclusive, prompt, and non-prompt ${\rm J}/\psi$ production
in p$-$Pb collisions at a nucleon$-$nucleon centre-of-mass energy
$\sqrt{s_{\mathrm{NN}}} = 5.02$ TeV is presented. The inclusive ${\rm J}/\psi$
mesons are reconstructed in the dielectron decay channel at midrapidity down to
a transverse momentum $p_{\rm T} = 0$. The inclusive ${\rm J}/\psi$ nuclear
modification factor $R_{\rm pPb}$ is calculated by comparing the new results in
p$-$Pb collisions to a recently measured proton$-$proton reference at the same
centre-of-mass energy. Non-prompt ${\rm J}/\psi$ mesons, which originate from
the decay of beauty hadrons, are separated from promptly produced ${\rm
J}/\psi$ on a statistical basis for $p_{\rm T}$ larger than 1.0 GeV/$c$. These
results are based on the data sample collected by the ALICE detector during the
2016 LHC p$-$Pb run, corresponding to an integrated luminosity ${\cal L}_{\rm
int} = 292 \pm 11 \; {\rm \mu b}^{-1}$, which is six times larger than the
previous publications. The total uncertainty on the $p_{\rm T}$-integrated
inclusive ${\rm J}/\psi$ and non-prompt ${\rm J}/\psi$ cross section are
reduced by a factor 1.7 and 2.2, respectively. The measured cross sections and
$R_{\rm pPb}$ are compared with theoretical models that include various
combinations of cold nuclear matter effects. From the non-prompt ${\rm J}/\psi$
production cross section, the ${\rm b\overline{b}}$ production cross section at
midrapidity, $\mathrm{d}\sigma_{\rm b\overline{b}}/\mathrm{d}y$, and the total
cross section extrapolated over full phase space, $\sigma_{\rm b\overline{b}}$,
are derived.
