f(R) Gravity: From the Pioneer Anomaly to the Cosmic Acceleration