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

Joins need to check that y is a data.table #14

Closed
hadley opened this issue Mar 8, 2016 · 4 comments
Closed

Joins need to check that y is a data.table #14

hadley opened this issue Mar 8, 2016 · 4 comments
Labels
bug an unexpected problem or unintended behavior dplyr-compat 💞 dplyr compatibility issues

Comments

@hadley
Copy link
Member

hadley commented Mar 8, 2016

Moved from tidyverse/dplyr#1217, by @Helix123

library(dplyr)
library(dplyr)

dt <- data.table::data.table(x = 1:3, y = 3:1)
df <- data.frame(x = 3:1, z = 1:3)

anti_join(dt, df)
left_join(dt, df)
@krlmlr
Copy link
Member

krlmlr commented Jun 19, 2016

The error message is not nice, but the following works as expected:

anti_join(dt, df, copy = TRUE)
left_join(dt, df, copy = TRUE)

Low prio.

@russellpierce

This comment has been minimized.

@hadley
Copy link
Member Author

hadley commented Jun 13, 2019

Probably need some special case like:

auto_copy_dt <- function(x, y) {
  if (is.data.frame(y)) {
    as.data.table(y)
  } else {
    dplyr::auto_copy(x, y, copy = copy)
  }
}

Latest reprex:

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

dt <- data.table::data.table(x = 1:3, y = 3:1)
df <- data.frame(x = 3:1, z = 1:3)

anti_join(dt, df)
#> Joining, by = "x"
#> Error in `[.data.frame`(y, , by$y, with = FALSE): unused argument (with = FALSE)
left_join(dt, df)
#> Joining, by = "x"
#> Source: local data table [3 x 3]
#> 
#> # A tibble: 3 x 3
#>       x     y     z
#>   <int> <int> <int>
#> 1     1     3     3
#> 2     2     2     2
#> 3     3     1     1

Created on 2019-06-13 by the reprex package (v0.2.1.9000)

@hadley hadley added bug an unexpected problem or unintended behavior dplyr-compat 💞 dplyr compatibility issues labels Jun 13, 2019
@hadley
Copy link
Member Author

hadley commented Jun 27, 2019

Resolved with lazy_dt methods:

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

dt <- lazy_dt(data.table::data.table(x = 1:3, y = 3:1))
df <- data.frame(x = 3:1, z = 1:3)

anti_join(dt, df)
#> Joining, by = "x"
#> Source: local data table [?? x 2]
#> Call:   `_DT1`[!`_DT2`, on = .(x)]
#> 
#> # … with 2 variables: x <int>, y <int>
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
left_join(dt, df)
#> Joining, by = "x"
#> Source: local data table [?? x 2]
#> Call:   merge(`_DT1`, `_DT3`, all.x = TRUE, all.y = FALSE, by = "x")
#> 
#>       x     y     z
#>   <int> <int> <int>
#> 1     1     3     3
#> 2     2     2     2
#> 3     3     1     1
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

Created on 2019-06-27 by the reprex package (v0.2.1.9000)

@hadley hadley closed this as completed Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior dplyr-compat 💞 dplyr compatibility issues
Projects
None yet
Development

No branches or pull requests

3 participants