This code works with dplyr 0.7.4, following the 'programming with dplyr' vignette.
Unfortunately, the rstudio server I use at work has dplyr 0.5.0, I do not have the ability to upgrade the package.
With 0.5.0 the code fails with "error: invalid argument type"
What modifications are necessary to 'backport' my function?
library(lubridate)
library(dplyr)
library(rlang)
samp <- tbl_df(seq.Date(as.Date("2017-01-01"), as.Date("2017-12-01"), by="day"))
count_x_month <- function(df, var, name){
var <- enquo(var)
name <- enquo(name)
name <- quo_name(name)
df %>%
filter(!is.na(!!var)) %>%
transmute(month := floor_date(!!var, "month")) %>%
group_by(month) %>%
summarise(!!name := n())
}
freq2 <- samp %>% count_x_month(value, out)
freq2