Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd median as one of the built-in aggregate functions for colDef #30
Comments
|
Hi, Thanks for the suggestion. Calculating the median is pretty straightforward, so I went ahead and added a reactable(
iris,
groupBy = "Species",
columns = list(Sepal.Length = colDef(aggregate = "median"))
)Passing R functions would be really cool, and totally possible I think. There'd be limitations though. JS aggregate functions run on the fly and update with table changes. For example, the aggregated values update when you filter this table: https://glin.github.io/reactable/articles/examples.html#aggregated-cell-rendering. R aggregated values would have to be precalculated and never change. But it's pretty much the same trade-off as JS vs. R render functions - much easier to write custom aggregators as an R programmer. Thanks for that suggestion as well! I've added it to my to-do list, but feel free to file a separate issue for it. |
|
Wow, thanks for the quick addition of the median! Ahh yes, I did not think about how the JS functions update the table when it is modified. Well, perhaps an Anyway, thanks for considering this! I will file its own issue. |
Hi @glin,
Wondering if it would be possible to add
median()as a built-inaggregatefunction forcolDef()? I know that the user can provide a customJS()function to do this on their own, so I could probably dig up enough JS to get it working, but I think median would be nice to have as a built-in.Actually, while I'm thinking of it, it would be nice to be able to pass R functions instead of/in addition to JS functions, if possible. That way one could pass the
medianfunction, or an anonymous function with some other aggregating capability. Thoughts?