Question using dplyr package and apply family function on two datasets