Spotted when investigating #5698
x = iris
class(x) = c("tbl","data.frame")
attr(x, "t1") = "a"
y = as.data.table(x)
attr(y, "t1")
#[1] "a" ## should be NULL
class(y)
#[1] "data.table" "data.frame"
We should assume creator of custom class provides correct data.frame method that clear any extra attributes
as.data.frame.tbl = function(x) {
attr(x, "t1") = NULL
class(x) = "data.frame"
x
}
z = as.data.frame(x)
attr(z, "t1")
#NULL
So then consistency can be retained, as described in #5698