如何解决在 R 可反应嵌套/分组表中提供 GROUP 信息详细信息
我正在使用 {reactable} 在 R 中创建一个表。
我使用的数据按物种分组
我希望在展开组行时能够获得组的详细信息。
{reactable} 文档中的示例仅展示了如何通过 ROW 索引提供详细信息。
我如何定位 GROUP 而不是行?
感谢您的帮助。
这是一个例子:
library(dplyr)
iris2 <- iris %>%
mutate(
group_info = case_when(
Species == "setosa" ~ "Info about the setosa group",Species == "versicolor" ~ "Info about the versicolor group",Species == "virginica" ~ "Info about the virginica group"
)
) %>%
group_by(Species)
reactable(iris2,groupBy = "Species",details = colDef(
name = "More",# i need to use the GROUP index,not the ROW index,however not sure how to implement this,would like the group_info to show on clicking/expanding the group
details = JS("function(rowInfo) {
return 'Details for row: ' + rowInfo.index +
'<pre>' + JSON.stringify(rowInfo.row,null,2) + '</pre>'
}"),html = TRUE,width = 60
))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。