【发布时间】:2016-07-16 14:24:01
【问题描述】:
下面提到的代码细节。
**server.R**
shinyServer(function(input, output) {
getTable <- reactive({
// Some manipulations done every 2 mins and table is updated
// Assume tbl_op has only one row with 3 columns
// The table values represent time in hh:mm:ss
tbl_op
})
output$tableUI <- renderTable({
getTable()
},include.rownames=FALSE)
})
**ui.R**
shinyUI(
fluidPage(
fluidRow(
column(width = 5, offset = 1,
tableOutput("tableUI")
)
)
)
)
我能够以所需的格式显示输出,但是我无法为其添加格式。
当时间差(系统时间与表格单元格中显示的值之间的绝对差值)超过 2 分钟时,我希望表格单元格值以红色突出显示。该表每两分钟更新一次。当差异超过 2 分钟时,应突出显示单元格值。
如果Datatable可以,请提供代码。
【问题讨论】:
-
可以对 Shiny 中显示的数据表应用条件格式,但这是一项相当复杂的练习,你看过this discussion 吗?如果我可以冒昧地提出另一个建议,您为什么不将您的代码重新发布为带有一些虚拟数据的单个
app.R文件?人们使用起来会更容易,我想看看这个但失去了兴趣,因为它看起来需要大量工作,因为必须生成所有数据和转换。