Roy C Roy C - 1 year ago 63
R Question

Unable to use DT::datatable on data.table::data.table object

I tried to create a DataTable in my Shiny App, with the following code:

output$table <- renderDataTable({

object is a data.table.
And I got this error:

Warning: Error in data.table inherits from data.frame (from v1.5) but this data.table does not. Has it been created manually (e.g. by using 'structure' rather than 'data.table') or saved to disk using a prior version of data.table? The correct class is c('data.table','data.frame').

Is it because I can't use data.table to create DataTable? What can I do?

Answer Source

Thanks @DaisyLee for pointing out this issue. It seems you managed to dig up a rather obscure and very old test that was improperly erroring on your code.

I filed an issue about the problem and pushed a fix.

Your code should now run on data.table versions 1.9.8+.

Once you update, you should be able to run the snippet of code you originally tried without error, and without needing to use or setDT.

In case you're interested, here's the code that was fixed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download