rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
587 stars 184 forks source link

update description of colReorder's order parameter #1094

Open ismirsehregal opened 8 months ago

ismirsehregal commented 8 months ago

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).

yihui commented 8 months ago

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!

gergness commented 8 months ago

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).

ismirsehregal commented 8 months ago

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).

gergness commented 8 months ago

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

ismirsehregal commented 8 months ago

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