This paper is an extension of the paper by Del Popolo et al. [Phys. Rev. D 101, 083505 (2020)] to take account of the effect of dynamical friction. We show how dynamical friction changes the threshold of collapse δc and the turnaround radius Rt. We numerically determine the relationship between the turnaround radius Rt and mass Mt in Λ CDM, dark energy scenarios, and an f(R) modified gravity model. Dynamical friction gives rise to a Rt-Mt relation differing from that of the standard spherical collapse. In particular, dynamical friction amplifies the effects of shear and vorticity already studied by Del Popolo et al. A comparison of the Rt-Mt relationships for Λ CDM, dark energy, and modified gravity models shows that the Rt-Mt relationship of Λ CDM is similar to that of the dark energy models, and small differences are seen when comparing with the f(R) models. The effects of shear, rotation, and dynamical friction are particularly evident at galactic scales, giving rise to a difference between the Rt-Mt relation of the standard spherical collapse of the order of ≃60%. Finally, we show how the new values of the Rt-Mt relation influence the constraints on the w parameter of the equation of state. Copyright © 2020 American Physical Society.