Datable:将formatStyle应用于数据的子集

Datable:将formatStyle应用于数据的子集,r,shiny,data-visualization,R,Shiny,Data Visualization,我希望在datatable上只对子集使用formatStyle 例如。 我想在使用formatStyle时排除最后的“总计”行。我试图使用下面的代码片段(不包括最后一行) artistTable7.data用虚拟数据集检查这一点 library(DT) options(DT.options = list(pageLength = 5)) df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)

我希望在
datatable
上只对子集使用
formatStyle

例如。

我想在使用formatStyle时排除最后的“总计”行。我试图使用下面的代码片段(不包括最后一行)


artistTable7.data用虚拟数据集检查这一点

library(DT)
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))

# using styleColorBar
datatable(df) %>% formatStyle(names(df),
                              background = styleColorBar(range(df), 'lightblue'),
                              backgroundSize = '98% 88%',
                              backgroundRepeat = 'no-repeat',
                              backgroundPosition = 'center')

使用虚拟数据集检查这一点

library(DT)
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))

# using styleColorBar
datatable(df) %>% formatStyle(names(df),
                              background = styleColorBar(range(df), 'lightblue'),
                              backgroundSize = '98% 88%',
                              backgroundRepeat = 'no-repeat',
                              backgroundPosition = 'center')

你能提供你正在尝试的数据和代码吗?你能提供你正在尝试的数据和代码吗?嗨,谢谢你的帮助。我刚刚编辑了代码。不会为环境设置选项()。我只想要这个特殊的数据表。嗨,谢谢你的帮助。我刚刚编辑了代码。不会为环境设置选项()。我只希望它用于这个特定的数据表。