Open moodymudskipper opened 7 months ago
Thanks. The following works, though, the difference is in the row.names
attribute:
library(tibble)
tb1 <- tibble(
e = structure(
list(list(4), list(5)),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA_integer_, -1L),
names = c("f", "g")
)
)
tb2 <- tibble(e = tibble::tibble(f = list(4), g = list(5)))
identical(tb1, tb2, attrib.as.set = FALSE)
#> [1] TRUE
attributes(tb1$e)
#> $class
#> [1] "tbl_df" "tbl" "data.frame"
#>
#> $row.names
#> [1] 1
#>
#> $names
#> [1] "f" "g"
attr(rbind(tb1)$e, "row.names")
#> [1] 1
attr(rbind(tb2)$e, "row.names")
#> [1] 1
Created on 2024-03-20 with reprex v2.1.0
I create two
identical()
tibbles but they behave differently. This is freaking me out.This is really hard to debug because
rbind()
doesn't call tibble explicitly, it's a non generic base function that callsInternal(rbind())
and in thererownames<-
is called and since it's generic we get into the tibble package.Do we set some global handlers that for some reason get triggered in one case and not the other ?
If we debug
rownames<-
we can hop into Internal(rbind()) and we see that :value
of"1"
and then with aNULL
value
.NULL
value
.