假设我有一个以下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
)?
答案 0 :(得分:1)
这应该有效
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。