【发布时间】:2016-03-04 11:33:12
【问题描述】:
我想将formatStyle 函数应用于我表中的不同列。我可以轻松地将相同的样式应用于所有列或列的某些子集,例如
divBySum <- function(x) x/sum(x)
output$test <- DT::renderDataTable(
datatable(mutate_each(mtcars, funs(divBySum)),
options = list(searching = FALSE,
paging = FALSE,
dom = 't'),
rownames = FALSE) %>%
formatStyle(colnames(mtcars),
background = styleColorBar(c(0, 1), 'lightgray'),
backgroundSize = '98% 88%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center') %>%
formatPercentage(colnames(mtcars))
)
但是我想将 不同 formatStyle 应用于每一列。例如,我想将条形的最大长度定义为styleColorBar(c(0, max(x)), 'lightgray'),其中x 是一列,或者它们的颜色不同。
我想使用一些将列名向量作为输入的函数来执行此操作。有什么好的、聪明的方法可以做到这一点?
【问题讨论】:
-
我想知道这里是否可以使用
tagList? github.com/hrbrmstr/vegalite/issues/3