Gauge invariant formulation of metric f (R) gravity for gravitational waves