Compute a rolling weighted sum by group
问题 I have a working example of a weighted sum of transactions over the last 12 hours. Now, I've added an account column and would like to compute this weighted sum separately by group. The code will run as written below. Uncomment the line starting with # account to add the account column to df . How can I modify the second to last line of code such that it computes rollapplyr separately on each account ? library(zoo) library(tidyverse) Create the example data: set.seed(123) randomDates <-