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

Can't join by list columns #2957

Closed
twolodzko opened this issue Jul 11, 2017 · 2 comments
Closed

Can't join by list columns #2957

twolodzko opened this issue Jul 11, 2017 · 2 comments

Comments

@twolodzko
Copy link

When trying to join by list columns I get the following (incorrect!) error message:

Error in left_join_impl(x, y, by$x, by$y, suffix$x, suffix$y, check_na_matches(na_matches)) : 
  Can't join on 'X' x 'X' because of incompatible types (list / list)

Below an example:

library(dplyr)

x <- tribble(
  ~ X,
  list(1),
  list(1:2),
  list(3)
)

y <- tribble(
  ~ X,
  list(1),
  list(1:2),
  list(5)
)

left_join(x, y, by = "X")

It would be great if it was possible to join by list columns, or at least the error message would inform that this is not possible.

@bhive01
Copy link

bhive01 commented Jul 12, 2017

Hello, you can in fact do this as I just recently discovered, but it's definitely more clunky than anticipated:
https://stackoverflow.com/questions/45062277/join-across-within-nested-dataframes
I'm not sure your example makes a lot of sense because if you're joining by the list column, what are you joining? You need another data column.

x <- tribble(
  ~ X,
  list(1),
  list(1:2),
  list(3)
) %>%
		mutate_all(funs(hash = map_chr(., digest::digest)))

y <- tribble(
  ~ X,
  list(1),
  list(1:2),
  list(5)
) %>%
		mutate_all(funs(hash = map_chr(., digest::digest)))

dplyr::left_join(x, y) 

It would be nice if this hashing was done for you though.

@krlmlr
Copy link
Member

krlmlr commented Jul 12, 2017

Thanks for reporting. #2355 is the canonical issue for this problem.

@krlmlr krlmlr closed this as completed Jul 12, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 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