DT icon indicating copy to clipboard operation
DT copied to clipboard

update description of colReorder's order parameter

Open ismirsehregal opened this issue 2 years ago • 5 comments

I just visited ?dataTableProxy

And I think the description of colReorder()'s order parameter needs an update - it is unclear to me:

A numeric vector of column positions, starting from 0, and including the row.names as a column, if they are include. Must contain a value for all columns, regardless of whether they are visible or not. Also for column reordering to work, the datatable must have extension 'ColReorder' set as well as option 'colReordoer' set to TRUE).

ismirsehregal avatar Nov 08 '23 08:11 ismirsehregal

This function was originally contributed by @gergness via the PR #527. It might be clearer if you read the documentation of DataTables: https://datatables.net/reference/api/colReorder.order()

Anyway, @gergness do you have time to contribute one more time to clarify the doc here? Thanks!

yihui avatar Nov 08 '23 14:11 yihui

Ha, never fun to re-read what I wrote a long time ago.

I'm having trouble improving the docs, I think the underlying functionality is confusing because the code is having to jump between javascript and R, so here's my first stab at it, but I wonder if @ismirsehregal has any suggestions:

A vector of column positions to reorder the columns in. This vector is passed directly to data.table javascript instance, so the indexing may behave differently than expected: it starts at 0, includes the row.names if they are displayed in the table, and also must include all column even those that have been hidden with hideCols() or showCols(). This functionality requires the datatable has extension 'ColReorder' turned on (see https://rstudio.github.io/DT/extensions.html).

gergness avatar Nov 08 '23 17:11 gergness

Thanks @gergness this is much better (I'm not a native speaker, so maybe my lack of understanding is partly my own fault).

What about:

A vector of column positions to reorder the columns in. This vector is passed directly to the datatable javascript instance, so the indexing starts at 0. Furthermore, it includes the column position of the row.names if they are displayed in the table. The vector also must include all hidden columns (see hideCols() or showCols()). This functionality requires the datatable has extension 'ColReorder' turned on (see https://rstudio.github.io/DT/extensions.html).

ismirsehregal avatar Nov 08 '23 18:11 ismirsehregal

Oh gosh, no, I don't think it made a ton of sense to native speakers either.

That seems good to me! Happy to make the PR or you can if you want @ismirsehregal

gergness avatar Nov 08 '23 18:11 gergness

Would be great if you make the PR (I'm currently only on mobile). Thank you!

ismirsehregal avatar Nov 08 '23 18:11 ismirsehregal