假设我有一个以下
datatable
对象,它对 mpg
列使用条件格式:
DT::renderDataTable(
datatable(mtcars,
options = list(
searching = FALSE,
pageLength = nrow(mtcars),
dom = 't'
),
rownames = FALSE,
selection = 'none') %>%
formatStyle('mpg',
background = styleColorBar(mtcars$mpg, 'lightblue'),
backgroundSize = '98% 88%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center'))
是否可以为
mpg
列定义条件格式,但条件格式直方图条的大小基于其他变量(例如disp
)?
这应该有效
datatable(mtcars,
options = list(
searching = FALSE,
pageLength = nrow(mtcars),
dom = 't'
),
rownames = FALSE,
selection = 'none') %>%
formatStyle('mpg','disp',
background = styleColorBar(mtcars$disp, 'lightblue'),
backgroundSize = '98% 88%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
请参阅 https://rstudio.github.io/DT/010-style.html 了解更多信息。