I have a data frame df_forecast, contains consumption data by date. Some dates are missing. So I thought to create another data frame considering the start date & end date of df_forecast & fill it with consecutive date then do left join with df_forecast & consider the last date value for the missing dates. So I wrote following code
startDate=min(df_forecast$Date1)
endDate=max(df_forecast$Date1)
dateSeq=seq(as.Date(startDate), as.Date(endDate), by="days")
df_date=data.frame(dateSeq)
But while I'm trying to merge df_date with df_forecast using below code
merge(df_date,df_forecast,by.x=dateSeq,by.y=Date1,all.x=True)
I'm getting error message
Error in fix.by(by.x, x) : 'by' must match numbers of columns Error in fix.by(by.x, x) : 'by' must match numbers of columns
Error in fix.by(by.x, x) : 'by' must match numbers of columns
Both the variables in merge by are Date data type. Can you suggest me how to solve this issue or any alternative approach?