Skip to content

Use child columns of a tibble column for joins #7659

@vorpalvorpal

Description

@vorpalvorpal

If I have a tibble containing a tibble column, it would be useful to be able to join based on the contents of a column within the tibble column.

df <- tibble(id = 1:5, tibbleCol = tibble(id = 2:6, value = 6:2), value = 3:7)
df2 <- tibble(id = 5:1, value = 8:4)
left_join(df, df2, by = c("tibbleCol$id" = "id"))
# Error in `left_join()`:
# ! Join columns in `x` must be present in the data.
# ✖ Problem with `tibbleCol$id`.

The above currently fails, but there is no obvious reason that it should do so, since the columns within a tibble column (unlike list columns or nested columns) are inherently the same length as the parent tibble.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions