-
Notifications
You must be signed in to change notification settings - Fork 135
Description
Currently as_tibble.data.frame() treats all extended data frames (class = <mydfclass, data.frame>) as if they were normal data frames (class = <data.frame>) and in turn ignores any as.data.frame() method that the object has available. A consequence of this manifested in #1555, and the follow up report in Rdatatable/data.table#5698, where additional attributes (only of use to {data.table}) were not removed on coercion.
In Rdatatable/data.table#5698, Jan proposed the following small addition as a possible solution:
as_tibble.data.frame = function(x, ...) {
if (!identical(class(x), "data.frame")) return(as_tibble(as.data.frame(x)))
... # continue old as_tibble.data.frame body
}This benefits not just {data.table} but any package that provides an extended object class. The onus is still on those packages to provide an as.data.frame() method but hopefully this is something they are already doing.
Happy to send a PR if receptive?