无法在可反应的情况下渲染没有行数的分组单元格
Cannot render grouped cells without row count in reactable
我正在使用 rMarkdown,编织到 html,并尝试在 reactable 中做一些简单的事情——使用 JS 来抑制括号中的行总数。我实际上是从他们自己的指南中复制的,但它不起作用:
reactable Grouped Cell Rendering
data <- MASS::Cars93[10:22, c("Manufacturer", "Model", "Type", "Price", "MPG.city")]
reactable(
data,
groupBy = c("Manufacturer", "Type"),
columns = list(
Manufacturer = colDef(
# Render grouped cells without the row count
grouped = JS("function(cellInfo) {
return cellInfo.value
}")
)
)
)
我收到以下错误:
Error in colDef(grouped = JS("function(cellInfo) {\n return cellInfo.value\n }")) :
unused argument (grouped = JS("function(cellInfo) {\n return cellInfo.value\n }"))
如有任何帮助,我们将不胜感激。
grouped
参数在 CRAN 版本的软件包中(尚)不可用。您可以从 github 安装开发版本,然后示例就可以运行了。
#install the package from github
#devtools::install_github("glin/reactable")
library(reactable)
data <- MASS::Cars93[10:22, c("Manufacturer", "Model", "Type", "Price", "MPG.city")]
reactable(
data,
groupBy = c("Manufacturer", "Type"),
columns = list(
Manufacturer = colDef(
# Render grouped cells without the row count
grouped = JS("function(cellInfo) {
return cellInfo.value
}")
),
Type = colDef(
# Render grouped cells with the row count, only if there are multiple sub rows
grouped = JS("function(cellInfo) {
if (cellInfo.subRows.length > 1) {
return cellInfo.value + ' (' + cellInfo.subRows.length + ')'
}
return cellInfo.value
}")
)
)
)
我正在使用 rMarkdown,编织到 html,并尝试在 reactable 中做一些简单的事情——使用 JS 来抑制括号中的行总数。我实际上是从他们自己的指南中复制的,但它不起作用:
reactable Grouped Cell Rendering
data <- MASS::Cars93[10:22, c("Manufacturer", "Model", "Type", "Price", "MPG.city")]
reactable(
data,
groupBy = c("Manufacturer", "Type"),
columns = list(
Manufacturer = colDef(
# Render grouped cells without the row count
grouped = JS("function(cellInfo) {
return cellInfo.value
}")
)
)
)
我收到以下错误:
Error in colDef(grouped = JS("function(cellInfo) {\n return cellInfo.value\n }")) :
unused argument (grouped = JS("function(cellInfo) {\n return cellInfo.value\n }"))
如有任何帮助,我们将不胜感激。
grouped
参数在 CRAN 版本的软件包中(尚)不可用。您可以从 github 安装开发版本,然后示例就可以运行了。
#install the package from github
#devtools::install_github("glin/reactable")
library(reactable)
data <- MASS::Cars93[10:22, c("Manufacturer", "Model", "Type", "Price", "MPG.city")]
reactable(
data,
groupBy = c("Manufacturer", "Type"),
columns = list(
Manufacturer = colDef(
# Render grouped cells without the row count
grouped = JS("function(cellInfo) {
return cellInfo.value
}")
),
Type = colDef(
# Render grouped cells with the row count, only if there are multiple sub rows
grouped = JS("function(cellInfo) {
if (cellInfo.subRows.length > 1) {
return cellInfo.value + ' (' + cellInfo.subRows.length + ')'
}
return cellInfo.value
}")
)
)
)