Merging Two Dataframes by date range
up vote
0
down vote
favorite
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?
r date
add a comment |
up vote
0
down vote
favorite
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?
r date
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 at 11:29
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
r date
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?
r date
r date
edited Nov 19 at 12:09
asked Nov 19 at 11:27
Quoros
144110
144110
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 at 11:29
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07
add a comment |
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 at 11:29
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07
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 at 11:29
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 at 11:29
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373646%2fmerging-two-dataframes-by-date-range%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 at 11:29
Possibly this answer applies: stackoverflow.com/questions/23934361/…
– snaut
Nov 19 at 14:07