You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability for summary functions to refer to columns other than the output column #690
In my experience it is uncommon to want to have a summary row in a table that uses a univariate function for all columns (as is the case in gt now - v0.2.2).
More commonly I want to apply, for example, a sum to some columns (such as trade value) and a weighted average to others (such as average trade price. In order to do this I would need a way for those functions to reference columns other than that for which the output is for. Such as the summary for column x should be sum(x*y)/sum(y)
changed the title [-]Add ability to specify different functions for different columns in summary rows[/-][+]Add ability for summary functions to refer to columns than the output column[/+]on Nov 20, 2020
changed the title [-]Add ability for summary functions to refer to columns than the output column[/-][+]Add ability for summary functions to refer to columns other than the output column[/+]on Nov 20, 2020
I ran into the same limitation. It would be nice if this capability was added in v0.4.0.
As a workaround (or dirty hack) I just passed a vector with the weights directly to the weighted.mean function. This would not work for tables with grouped rows though.
Activity
[-]Add ability to specify different functions for different columns in summary rows[/-][+]Add ability for summary functions to refer to columns than the output column[/+][-]Add ability for summary functions to refer to columns than the output column[/-][+]Add ability for summary functions to refer to columns other than the output column[/+]rich-iannone commentedon Dec 1, 2020
This is a great idea, thanks for posting it here. Totally agree that summarizing is a bit simplistic right now.
nicomunting commentedon Dec 21, 2021
I ran into the same limitation. It would be nice if this capability was added in v0.4.0.
As a workaround (or dirty hack) I just passed a vector with the weights directly to the
weighted.meanfunction. This would not work for tables with grouped rows though.By the way, is this not a duplicate of #383?
rich-iannone commentedon Aug 25, 2022
Now solved with #1018