FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

as.data.table should remove extra attributes from extended data.frames · Issue #5699 · Rdatatable/data.table · GitHub

as.data.table should remove extra attributes from extended data.frames #5699

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL