Skip to content

Instantly share code, notes, and snippets.

@chadsten
Created September 12, 2018 19:06
Show Gist options
  • Save chadsten/55d0b55171bf3019e2c4714646156cc3 to your computer and use it in GitHub Desktop.
Save chadsten/55d0b55171bf3019e2c4714646156cc3 to your computer and use it in GitHub Desktop.
# compile Q1 data
q1_data <- weight_hits(IR, 0, 3, 1)
weight_hits <- function(data, start, end, weight) {
result <- filter(IR, OrderDate < Sys.Date() - months(start), OrderDate >= Sys.Date() - months(end)) %>%
group_by(PartNum, Plant) %>%
summarise(hits = n() * weight)
return(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment