Simple MapReduce function in R