0

I have a reactable table in an R Shiny app that looks like this: enter image description here

Is there a way to add a row number or rank column that dynamically changes based on which column is sorted? So if the Carries column is sorted from high-to-low, the new column would have the player with the most carries as 1, the player with the second most carries as 2, so on and so forth. enter image description here

Sam Hoppen
  • 355
  • 2
  • 9
  • 1
    Can you clarify what you mean with 'dynamically changes'? Should the row number be fixed to each observation? If you simply want to add row IDs to your data frame you can use: your.data.frame %>% rowid_to_column() – SEcker Sep 07 '22 at 07:10
  • 1
    @SEcker by dynamically I mean that it changes based on the column that's sorted. As far as I know, sorting in reactable doesn't change the dataframe, it just changes the order of things. – Sam Hoppen Sep 07 '22 at 14:33
  • Assuming that you want to get back the sorted data frame, I think there is currently no straightforward way to do it. You would need to look into the JavaScript API of reactable. Maybe this open issue can help you https://github.com/glin/reactable/issues/265 – SEcker Sep 09 '22 at 06:22

0 Answers0