r repeat function for each column