Skip to content

Join columns mislabelled #137

@ShixiangWang

Description

@ShixiangWang

Thanks for making this nice tool firstly. I got an error when I tried to rewrite code with dtplyr. I debugged the code and found the left_join() returns the result of right join and vice versa.

library(dplyr, warn.conflicts = FALSE)
library(data.table)
library(dtplyr)


a <- lazy_dt(data.table(x_left = 1:3, y = 1))
b <- lazy_dt(data.table(x_right = 2:4, z = 2))

left_join(a, b, by=c("x_left"="x_right"))

Join result

> left_join(a, b, by=c("x_left"="x_right"))
Source: local data table [?? x 4]
Call:   `_DT2`[`_DT1`, on = .(x_right = x_left), allow.cartesian = TRUE]

  x_right     z     y
    <int> <dbl> <dbl>
1       1    NA     1
2       2     2     1
3       3     2     1

# Use as.data.table()/as.data.frame()/as_tibble() to access results

> left_join(as_tibble(a), as_tibble(b), by=c("x_left"="x_right"))
# A tibble: 3 x 3
  x_left     y     z
   <int> <dbl> <dbl>
1      1     1    NA
2      2     1     2
3      3     1     2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions