【发布时间】:2019-07-23 09:57:20
【问题描述】:
我希望为每个数字列设置颜色格式,以便根据每列的范围显示一个蓝色范围栏。这是一张关于我想要实现的目标的照片。
#Here is the the table I have so far.
#I am adding filters to the columns. This works great
library(DT)
library(magrittr)
df = datatable(iris, filter = 'top', options = list(pageLength = 5, autoWidth = TRUE))
#I try to add the blue bars here to the first 2 numeric columns
df %>%formatStyle(names(df)[1:2],
background = styleColorBar(range(df[,1:2]), 'lightblue'),
backgroundSize = '98% 88%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
Error in df[, 1:2] : incorrect number of dimensions
如果有一个功能可以自动在所有数字列上放置蓝条,那就太好了。提前致谢
【问题讨论】:
标签: r shiny datatables dt