Manipulate data in R with dplyr joins and windows | Upstart SQL Question