【发布时间】:2018-08-16 23:29:00
【问题描述】:
我有一个数据集:
ID Value
102 306
41 800
101 783
105 193
myID 334
我想将其绘制为一个数据表,其中只有带有“myID”的行是橙色的,表的其余部分是蓝色的。看过helper functions 和other examples,看来我应该使用styleEqual。但是,我不知道其他行中的值是什么,它们也会动态变化。
我尝试过使用
datatable(tableData) %>%
formatStyle(0, target= 'row',color = 'black', backgroundColor = tableColour,
lineHeight='70%', padding = '3px 3px', fontSize = '80%') %>%
formatStyle('ID', target = 'row',
backgroundColor = styleEqual(c("myID"), c('orange')))
但是,这不起作用 - 整个表是蓝色的,第二个 formatStyle 语句被忽略。如果我删除第一个 formatStyle,我的行会变成橙色,但会丢失所有其他格式。有没有办法使用 styleEqual 来定义例如c("myID", "All other IDs"),还是有其他解决方法?
【问题讨论】: