0

Two Dataframes: A - Companies with their Listing Date, B - Daily Trading Data After One Year.

Problem - Merging Data by incrementing listing date by one year creates NA values as some dates fall on weekends or holidays. Need to find dates near the one-year mark.

Any ideas?

Quoros
  • 184
  • 1
  • 10
  • you can find weekdays with wday function in lubridate and later subset the data only based on weekdays , here is a short example library(dplyr) library(lubridate) df <- data_frame(date = seq(ymd("2018-06-01"), ymd("2018-09-30"), by = "days")) days <- mutate(df, day = wday(date, label = T)) %>% filter(day != "Sat", day != "Sun") %>% nrow() – Hunaidkhan Nov 19 '18 at 11:29
  • Possibly this answer applies: https://stackoverflow.com/questions/23934361/merge-2-dataframes-if-value-within-range – snaut Nov 19 '18 at 14:07

0 Answers0