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

split dropping custom class · Issue #7105 · Rdatatable/data.table · GitHub

split dropping custom class #7105

Description

Not sure if this is the expected behaviour, but split drops custom classes when using the by arg but it keeps them when using the f arg.

library(data.table)

dt = data.table(x = letters[1:10], y = 1:10, z = rnorm(10))
setattr(dt, "class", c("my_class", class(dt)))
# using f
dt |> split(~x) |> lapply(class) |> unlist() |> unique()
#> [1] "my_class"   "data.table" "data.frame"
# using by
dt |> split(by = "x") |> lapply(class) |> unlist() |> unique()
#> [1] "data.table" "data.frame"

Created on 2025-06-28 with reprex v2.1.1

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

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL