I currently have two dataframes, each with a date column and then several columns of numeric data. The first dataframe, "daily", has data that is approximately but not exactly daily in periodicity while the second dataframe, "weekly", has data that is approximately but not exactly weekly in periodicity. What I would like to accomplish is to replace the "weekly" dataframe with one that has the same dates as "daily" and backfills data with the previous value for any missing values. I know that I can use na.locf from the zoo package to backfill the data but I am unsure as to how I can effectively introduce the dates from the "daily" dataframe. Perhaps some variation of a merge or join?
daily<-data.frame( date1=rep(seq(as.Date("2000-01-01"), as.Date("2000-09-10"), by="1 day"), each=1), value1=runif(254), value2=rnorm(254), value3=rpois(254,10) ) weekly<-data.frame( date2=rep(seq(as.Date("2000-01-01"), as.Date("2000-09-10"), by="1 week"), each=1), value4=runif(37), value5=rnorm(37), value6=rpois(37,10) ) "result" should have date1 and then value4, value5, and value6 as columns and then na.locf can be used to backfill any missing data.