Add totals row for numeric columns in DT tables
Hi!
I've been trying to add a final row for a DT table (in a Shiny app) with no success. I think it is a super useful option that would benefit lots of us, happy users!
Is it possible to add like an options = list(..., totals) with sum or mean or any operation for any given column? I know this is more of a request (not a bug) but would really appreciate your help.
Thanks 👍
By filing an issue to this repo, I promise that
- [x] I have fully read the issue guide at https://yihui.name/issue/.
- [ ] I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/DT'). - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
You could use a footerCallback. See https://github.com/rstudio/DT/issues/451.
Thanks. I think it's a good idea to have an option here... Features I can think of:
- display all the numeric column's sum-up on the page by default
- being able to control which columns to display the sum-up
- showing the sum-up of the selected rows/cells...
@shrektan that sounds incredible! Let me know if I can help you with any of that. Thanks again and 15 thumbs up for you! Hope you succeed with this project 👍
hi there, I was just wondering if this enhancement was going to be implemented at some point. It would be very useful.
Thanks
Looking forward for this enhancement too. Adding a total row in the bottom of a DT::datatable(). Really grateful for this package. Thanks.
Edit: it would be amazing creating the effect of the function = janitor::adorn_totals("row") inside DT functions. My recommendation
Any news on this? would be great to have such a function!