The phase-space view of f(R) gravity