背景:
我正在尝试将 data.frame 插入到 rShiny 中的 renderDataTable 对象中。我的 data.frame 填充没有任何问题:
然而,我闪亮的仪表板出错了并且没有读取表格,尽管它填充了它。
由于数据是私有的,因此我无法共享数据,但是我希望您能帮助我了解闪亮的概述,以帮助我理解我的问题。
代码:
observe({
filtered.df <- MetricsDataFrame[MetricsDataFrame$test == input$test,]
filtered.df[5, (3:8)] <- colSums(filtered.df[,3:8])
})
output$test_table <- DT::renderDataTable(
filtered.df %>%
DT::datatable(
options = list(
dom = 't',
digits = 0,
rownames = FALSE
)
) %>%
DT::formatCurrency(
columns = cols,
currency = "$"
) %>%
DT::formatRound(
columns = cols,
digits = 0
) %>%
DT::formatStyle(
columns = cols,
color = DT::styleInterval(0, c('red', 'green')) #,
# #backgroundColor = styleInterval(3.4, c('gray', 'yellow'))
)
)
编辑:
我尝试将观察更改为反应函数。但我仍然没有看到任何结果。
df.table <- reactive({
filtered.df <- MetricsDataFrame[MetricsDataFrame$test == input$test,]
filtered.df[5, (3:8)] <- colSums(filtered.df[,3:8])
})