Created
April 20, 2017 10:54
-
-
Save nathan-russell/fed1ac78daf600a98c827d6a4d8adafb 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
df1 <- structure(list(numWeek = structure(c(10959, | |
10966, 10973, 10980, 10987, 10994, 11001, 11008, 11015, 11022, | |
11029, 11036), class = "Date")), .Names = "numWeek", row.names = c(NA, | |
-12L), class = "data.frame") | |
df2 <- structure(list(effective = c(1, 1, 1, 1, 1, 1, 4, 3, 4, 5, 8, | |
4), numWeek = c("2000-01-03", "2000-02-14", "2000-02-28", "2000-03-13", | |
"2000-04-10", "2000-05-01", "2000-05-08", "2000-05-15", "2000-05-22", | |
"2000-05-29", "2000-06-05", "2000-06-12")), .Names = c("effective", | |
"numWeek"), row.names = c(NA, 12L), class = "data.frame") | |
df2$numWeek <- as.Date(df2$numWeek) | |
merge( | |
x = df1, | |
y = df2, | |
by = "numWeek", | |
all.x = TRUE | |
) | |
# numWeek effective | |
# 1 2000-01-03 1 | |
# 2 2000-01-10 NA | |
# 3 2000-01-17 NA | |
# 4 2000-01-24 NA | |
# 5 2000-01-31 NA | |
# 6 2000-02-07 NA | |
# 7 2000-02-14 1 | |
# 8 2000-02-21 NA | |
# 9 2000-02-28 1 | |
# 10 2000-03-06 NA | |
# 11 2000-03-13 1 | |
# 12 2000-03-20 NA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment