R function to use Rubin's rule