powerjoin icon indicating copy to clipboard operation
powerjoin copied to clipboard

Check failures on R-devel

Open krlmlr opened this issue 1 year ago • 0 comments

Root cause: The following code behaves differently in R-devel.

x <- structure(
  list(
    id1 = structure(
      c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L),
      levels = c("a", "b", "d"),
      class = "factor"
    ),
    id2 = c(1, 1, 1, 3, 3, 3, NA, NA, NA)
  ),
  out.attrs = list(
    dim = c(id1 = 3L, id2 = 3L),
    dimnames = list(id1 = c("id1=a", "id1=b", "id1=d"), id2 = c("id2= 1", "id2= 3", "id2=NA"))
  ),
  class = "data.frame",
  row.names = c(NA, -9L)
)
y <- structure(
  list(
    id1 = structure(c(1L, 1L, 2L, 3L), levels = c("a", "b", "d"), class = "factor"),
    id2 = c(1, 1, 3, NA)
  ),
  row.names = c(NA, -4L),
  class = "data.frame"
)

setdiff(x, y)
#> $id1
#> [1] a b d a b d a b d
#> Levels: a b d
#> 
#> $id2
#> [1]  1  1  1  3  3  3 NA NA NA

Created on 2024-12-29 with reprex v2.1.1

I do wonder about the semantics here, though. Do you need vctrs::vec_set_difference() ?

setdiff(data.frame(a = 1:3, b = 2), data.frame(a = 2L, b = 2))
#> $a
#> [1] 1 2 3
#> 
#> $b
#> [1] 2 2 2

x <- structure(
  list(
    id1 = structure(
      c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L),
      levels = c("a", "b", "d"),
      class = "factor"
    ),
    id2 = c(1, 1, 1, 3, 3, 3, NA, NA, NA)
  ),
  out.attrs = list(
    dim = c(id1 = 3L, id2 = 3L),
    dimnames = list(id1 = c("id1=a", "id1=b", "id1=d"), id2 = c("id2= 1", "id2= 3", "id2=NA"))
  ),
  class = "data.frame",
  row.names = c(NA, -9L)
)
y <- structure(
  list(
    id1 = structure(c(1L, 1L, 2L, 3L), levels = c("a", "b", "d"), class = "factor"),
    id2 = c(1, 1, 3, NA)
  ),
  row.names = c(NA, -4L),
  class = "data.frame"
)

vctrs::vec_set_difference(x, y)
#>   id1 id2
#> 1   b   1
#> 2   d   1
#> 3   a   3
#> 4   d   3
#> 5   a  NA
#> 6   b  NA

Created on 2024-12-29 with reprex v2.1.1

krlmlr avatar Dec 29 '24 06:12 krlmlr