Apply function to multiple data frames r