Mastering dplyr Grouping Data by External Variables