Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when joining on lubridate intervals #3353

Closed
moodymudskipper opened this issue Feb 12, 2018 · 3 comments
Closed

Issue when joining on lubridate intervals #3353

moodymudskipper opened this issue Feb 12, 2018 · 3 comments

Comments

@moodymudskipper
Copy link

moodymudskipper commented Feb 12, 2018

This prints an inappropriate result:

library(tidyverse)
res <- tibble(a = rep("a", 3), b = rep(make_date(2001) %--% make_date(2002), 3)) %>% 
  left_join(tibble(a = rep("a", 3), c = rep(make_date(2002) %--% make_date(2003)))

# A tibble: 9 x 3
      a                              b                              c
  <chr>                 <S4: Interval>                 <S4: Interval>
1     a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
2     a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
3     a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
4     a                         NA--NA                         NA--NA
5     a                         NA--NA                         NA--NA
6     a                         NA--NA                         NA--NA
7     a                         NA--NA                         NA--NA
8     a                         NA--NA                         NA--NA
9     a                         NA--NA                         NA--NA

res$b@start
[1] "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC"

Using merge works fine

res <- tibble(a = rep("a", 3), b = rep(make_date(2001) %--% make_date(2002), 3)) %>% 
merge(tibble(a = rep("a", 3), c = rep(make_date(2002) %--% make_date(2003))),all.x=TRUE) 
 
a                              b                              c
1 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
2 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
3 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
4 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
5 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
6 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
7 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
8 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
9 a 2001-01-01 UTC--2002-01-01 UTC 2002-01-01 UTC--2003-01-01 UTC
res$b@start
[1] "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC" "2001-01-01 UTC"
[8] "2001-01-01 UTC" "2001-01-01 UTC"
@cderv
Copy link
Contributor

cderv commented Feb 12, 2018

Possible duplicates of #3217
There is still an open issue in #2432 that relates to this too.

@krlmlr
Copy link
Member

krlmlr commented Feb 28, 2018

Thanks, #2432 is the generic issue.

@krlmlr krlmlr closed this as completed Feb 28, 2018
@lock
Copy link

lock bot commented Aug 27, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Aug 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants