Skip to content

Creation of data.table using a list #968

@asantucci

Description

@asantucci

This is a very similar issue as what is mentioned here: http://stackoverflow.com/questions/18390947/data-table-of-table-is-very-different-from-data-frame-of-table

yet this pertains to creating data.tables using a list input. For example:

### Data.frame takes in a list of 3 3x3 matrices, and creates a 3x9 data.frame.
data.frame(replicate(3, matrix(rnorm(9), nrow = 3)))

### Data.table takes in the same list, and creates a 27x1 data.table.
data.table(replicate(3, matrix(rnorm(9), nrow = 3)))

I discovered this behavior at least a year ago when I was trying to create a data.table object using mget

a <- letters
b <- LETTERS
vars <- c("a", "b")

### Works
data.frame(mget(vars))

### Doesn't work
data.table(mget(vars))

There are probably really good reasons for having this behavior that I am not aware of as a user, but at the same time it would be great to have data.table behaving as similarly as possible to data.frame!

Thanks for such a great package! I haven't used data.frame in years, and couldn't be happier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions