My question is simple: I am working on a Shiny app, using the datatable package. I am displaying a table with DT::datatable()
and I want to use its order
option to specify an initial ordering of the rows of the table. The help I could find here tells me I can use some syntax like order = list(list(2, 'asc'), list(4, 'desc'))
to order using first ascending order of column 2 and then descending order of column 4, but instead of using column indices, I want to use column names. If I were using the underlying DataTables library in JavaScript, it seems I would be able to do just that: see here.
Question: What is the appropriate syntax for me to write such an sorting specification inside a Shiny app, within the order()
option of DT::datatable()
? I tried stuff like list(list(name = "animalID", dir = "asc"), list(4, "desc"))
, to no avail. TIA for your help.