For abelian groups, the existence of left inverse or right inverse of a homomorphism can be characterized by looking at whether the image or kernel splits the group. Is there an analogous characterization for ring homomorphisms? Specifically, if $f:R\rightarrow S$ be a ring homomorphism, when does there exist a ring homomorphism $g:S\rightarrow R$ such that $f\circ g=\mathrm{Id}_S$ or $g\circ f=\mathrm{Id}_R$ ?
Edit: Let's restrict to commutative rings for now.
I don't think there's anything nice to say in general. This is a fairly delicate problem.
Consider just the case of left inverses. Here is the sort of thing that can go wrong: take $f : k \to k[x]/f(x)$. Then a left inverse exists iff there exists $r \in k$ such that $f(r) = 0$, and e.g. if $k$ is a non-algebraically closed field this won't exist most of the time. More generally we can take maps like $f : \mathbb{Z} \to \mathbb{Z}[x_1, ..., x_n]/(f_1, f_2, ..., f_m)$ and we see that the problem of determining whether there exists a left inverse is at least as hard as the problem of determining whether a system of Diophantine equations has an integer solution, which is known to be undecidable in a particular sense by Matiyasevich's theorem. These examples show in particular that it doesn't suffice to assume that $f$ is a monomorphism or even that it makes $S$ a finite rank free $R$-module.
(Thinking of this question as a question about commutative rings, then as a question about affine schemes, note that the analogous question for spaces includes as a special case the question of whether a bundle admits a section, which is a pretty nontrivial question, e.g. it admits in turn as a special case the question of whether a manifold is parallelizable. I think one can rephrase this entirely as a question about C*-algebras if the manifold is compact, and already it's a nontrivial question to characterize the parallelizable spheres.)
Edit: I wrote a blog post exploring the topological analogue in more detail.