Evolution of cosmological gravitational waves in f(R) gravity