DT icon indicating copy to clipboard operation
DT copied to clipboard

Add totals row for numeric columns in DT tables

Open laresbernardo opened this issue 6 years ago • 6 comments

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.

laresbernardo avatar Aug 26 '19 10:08 laresbernardo

You could use a footerCallback. See https://github.com/rstudio/DT/issues/451.

stla avatar Aug 28 '19 08:08 stla

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 avatar Aug 28 '19 14:08 shrektan

@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 👍

laresbernardo avatar Aug 28 '19 15:08 laresbernardo

hi there, I was just wondering if this enhancement was going to be implemented at some point. It would be very useful.

Thanks

grusheInvestec avatar Aug 26 '20 10:08 grusheInvestec

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

aito123 avatar Oct 20 '21 17:10 aito123

Any news on this? would be great to have such a function!

PilarRius avatar Jul 18 '22 15:07 PilarRius