BROKEN:renderDataTable中的反应元素 - R Shiny

时间:2018-04-05 14:19:30

标签: r dataframe shiny subset shiny-reactivity

背景:

我正在尝试将data.frame插入到rShiny中的renderDataTable对象中。我的data.frame填充没有任何问题:

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])

})

0 个答案:

没有答案