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

Implement nest_join #3570

Closed
hadley opened this issue May 11, 2018 · 6 comments
Closed

Implement nest_join #3570

hadley opened this issue May 11, 2018 · 6 comments

Comments

@hadley
Copy link
Member

@hadley hadley commented May 11, 2018

A nest_join() would create a list-column:

library(tibble)

df1 <- tibble(x = c(1, 2), y = c(2, 3))
df2 <- tibble(x = c(1, 1), z = c(2, 3))

# nest_join(df1, df2)
# Would yield:
out <- df1
out$df2 <- list(df2, NULL)
out
#> # A tibble: 2 x 3
#>       x     y df2             
#>   <dbl> <dbl> <list>          
#> 1     1     2 <tibble [2 × 2]>
#> 2     2     3 <NULL>

The output would always have exactly the same rows as the input, but with one new column, named (by default) with the name of y. unnest()ing this data frame would yield an inner_join() (or a left_join() with tidyverse/tidyr#358)

@romainfrancois how hard would this be to implement?

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented May 11, 2018

I think we have most of the internal tools that we need. Would the nested tibbles have the x column in the example or just z ?

@hadley
Copy link
Member Author

@hadley hadley commented May 11, 2018

Hmmmm, good question; for now, I'd say let's drop the join columns from the nested column — that way unnest() will create the same thing as an inner join.

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented May 11, 2018

That makes it easier to test it. I’ll 🤹‍♂️ with this, should be easy enough.

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented May 11, 2018

Is NULL ok or should it be a 0 rows data frame of the right format ?

@hadley
Copy link
Member Author

@hadley hadley commented May 11, 2018

0-row data frame I think.

romainfrancois added a commit that referenced this issue May 12, 2018
romainfrancois added a commit that referenced this issue May 27, 2018
romainfrancois added a commit that referenced this issue May 27, 2018
@lock
Copy link

@lock lock bot commented Nov 24, 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 Nov 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants