Farrel
Farrel

Reputation: 10444

In R, what can a data.table column store? Simple examples please

Data.table package is amazing. I know I can store a vector in a column. That vector can be strings or numbers. I know I can store lists.

What else can I store? I recall that I could store models, data.tables, xml documents in a data.table. Am I confabulating? I fear I am since I am having a hard time finding straight-forward resources telling me how to store and manipulate these objects in a data.table.

Upvotes: 0

Views: 257

Answers (1)

MichaelChirico
MichaelChirico

Reputation: 34703

Most types are valid through data.table() but the range of well-supported classes is narrower. Mostly, to keep anything in a data.table you can put it in a list column.

Note that not all data.table operations are supported for all types, however.

To wit, we only offer sorting for atomic types (see ?is.atomic). Sorting is the workhorse behind grouping by= and joins (on= / merge), so if your grouping column or is a list, you're out of luck. Joining using complex columns is also not supported.

Please feel free to report to our issue tracker with use cases of anything that's not supported.

Upvotes: 4

Related Questions