Over the past few decades, general relativity and the concordance ΛCDM model have been successfully tested using several different astrophysical and cosmological probes based on large datasets (precision cosmology). Despite their successes, some shortcomings emerge due to the fact that general relativity should be revised at infrared and ultraviolet limits and to the fact that the fundamental nature of dark matter and dark energy is still a puzzle to be solved. In this perspective, f (R) gravity has been extensively investigated, being the most straightforward way to modify general relativity and to overcame some of the above shortcomings. In this paper, we review various aspects of f (R) gravity at extragalactic and cosmological levels. In particular, we consider a cluster of galaxies, cosmological perturbations and N-body simulations, focusing on those models that satisfy both cosmological and local gravity constraints. The perspective is that some classes of f (R) models can be consistently constrained by the large-scale structure.