Cosmological viability of f(R)-gravity as an ideal fluid and its compatibility with a matter dominated phase