Skip to content

tables could look for en-list-ed data.tables as well #2606

Open
@MichaelChirico

Description

I don't think it's too uncommon to have objects like

list(data.table(a = 1, b = 4:6)),
      data.table(a = 2, b = 7:10))

sitting around in one's workspace. It seems tables should look for these objects as well -- they could come from split.data.table, or, eventually, from fread (#2582).

I'm not too worried about recursive nesting, and would eschew looking for data.tables that are nested within data.table/data.frame objects.

Activity

MichaelChirico

MichaelChirico commented on May 8, 2019

@MichaelChirico
MemberAuthor

I think recursive argument would be helpful and a basic version pretty straightforward to implement

markseeto

markseeto commented on Sep 9, 2023

@markseeto
Contributor

@MichaelChirico I'm a beginner with PRs but I'm interested in working on this.

Can you please clarify how the modified tables() function should behave? Here's an example:

library(data.table)

DT_A <- data.table(A1 = 1:5, A2 = letters[1:5])

DT_B <- data.table(B1 = 1:10, B2 = 11:20, B3 = 0)

DT_list1 <- list(data.table(X1 = 1:3, X2 = 5),
                 data.table(Y1 = 1:5, Y2 = 11:15, Y3 = 101:105))

DT_list2 <- list(DT_Z = data.table(Z1 = 1:10),
                 numbers = 1:5)
# DT_list2$numbers is not a data.table

tables()

#    NAME NROW NCOL MB     COLS KEY
# 1: DT_A    5    2  0    A1,A2
# 2: DT_B   10    3  0 B1,B2,B3
# Total: 0MB

Do you think the data.tables in DT_list1 and DT_list2 should appear in the same table as DT_A and DT_B, or should they appear in a separate table?

That is, should the output of tables() be something like this:

            NAME NROW NCOL MB     COLS KEY
1:          DT_A    5    2  0    A1,A2
2:          DT_B   10    3  0 B1,B2,B3
3: DT_list1[[1]]    3    2  0    X1,X2
4: DT_list1[[2]]    5    3  0 Y1,Y2,Y3
5: DT_list2$DT_Z   10    1  0       Z1
Total: 0MB

Or something like this:

data.tables:
            NAME NROW NCOL MB     COLS KEY
1:          DT_A    5    2  0    A1,A2
2:          DT_B   10    3  0 B1,B2,B3
Total: 0MB

Lists of data.tables:
   LIST_NAME DT_NAME NROW NCOL MB     COLS KEY
1:  DT_list1  <NULL>    3    2  0    X1,X2
2:  DT_list1  <NULL>    5    3  0 Y1,Y2,Y3
3:  DT_list2    DT_Z   10    1  0       Z1
Total: 0MB

Or something else?

And when you say you're not too worried about recursive nesting, does that mean that if we had

DT_list3 <- list(list(DT3a = data.table(X1 = 1:3, X2 = 1:3),
                      DT3b = data.table(X1 = 1:4, X2 = 1:4)),
                 list(DT3c = data.table(X1 = 1:5, X2 = 1:5),
                      DT3d = data.table(X1 = 1:6, X2 = 1:6)))

then the four data.tables in DT_list3 wouldn't need to appear in the output of tables()?

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      tables could look for en-list-ed data.tables as well · Issue #2606 · Rdatatable/data.table