I have a R data frame, which daily level data with a single date column and rest 4-5 other columns, i am using the pad function in dplyer to fill in missing dates within a series of data. Group2 is a list of column name stored in a variable.
data_padded <- data_df%>% pad(group = GROUP2)
but then it always pads for a day interval rather than determining from the data if it needs day, week, month etc intervals as the data has column name "Date_level" which has values like 'daily', weekly', 'monthly'.
If we can somehow use the date_level column in the dataframe to say,
if Date_level=' weekly' then
padded_data <- data_padded %>%
pad(group = GROUP2, interval = "week")
if Date_level='daily' then
data_padded <- data_padded %>% pad(group = GROUP2, interval = "day")
if Date_level='monthly' then
padded_data <- data_padded %>% pad(group = GROUP2, interval = "month")
so that I could the interval property in pad function to pad according the date level.