Hi RStudio Community,
I usually pad my dataset to add rows with missing dates using the following script
library(padr)
dataset_new <- dataset_old
group_by(var1, var2, var3,var4, var5, var6, date_var)%>%
summarise(event=sum(event)) %>%
arrange(var1, var2, var3,var4, var5, var6, date_var) %>%
group_by(var1, var2, var3,var4, var5, var6) %>%
pad(start_val = ymd("2015-01-01")) %>%
fill_by_value(event, 0) %>%
ungroup() %>%
complete(var1, var2, var3,var4, var5, var6, date_var, fill = list(event= 0))
However, I'm working with a very large dataset, and I'm getting the following error code:
Instead of grouping by the date_var and padding the data based on this variable, can I use the pad() function to pad the data using a character date variable such as date_char== "2015-09". P.s. I would like to first aggregate the data by month, instead of the exact date, and use the pad function to add rows with missing months (instead of dates).
QUESTION
How to use the pad() function to insert rows with missing months based on the date_char variable instead of the date_var variable?
Thanks in advance!!