  We investigate cosmological dynamics based on $f(R)$ gravity in the Palatini
formulation. In this study we use the dynamical system methods. We show that
the evolution of the Friedmann equation reduces to the form of the piece-wise
smooth dynamical system. This system is is reduced to a 2D dynamical system of
the Newtonian type. We demonstrate how the trajectories can be sewn to
guarantee $C^0$ extendibility of the metric similarly as `Milne-like' FLRW
spacetimes are $C^0$-extendible. We point out that importance of dynamical
system of Newtonian type with non-smooth right-hand sides in the context of
Palatini cosmology. In this framework we can investigate singularities which
appear in the past and future of the cosmic evolution. We consider cosmological
systems in both Einstein and Jordan frames. We show that at each frame the
topological structures of phase space are different.
