Last active
July 19, 2022 09:14
-
-
Save dwinter/3cd1e22c2183b3b190cf6e1c820c4280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(lubridate) | |
library(dplyr) | |
#fake data as an example, just 4 ranodm dates in the last month | |
set.seed(123) | |
fake_data_a <- data.frame(date = today() - sample(30,4), value_a=rnorm(4)) | |
fake_data_b <- data.frame(date = today() - sample(30,4), value_b=rnorm(4)) | |
#find all the dates in the window dfeine by fake_data_a | |
all_dates <- data.frame(date = seq(min(fake_data_a$date), max(fake_data_a$date), by=1)) | |
#join up both tables, `reduce` here is just 'keep calling left join' | |
all_dates_both_values <- purrr::reduce(list(all_dates, fake_data_a, fake_data_b) , left_join, by="date") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment