【问题标题】:Subsetting shinyTable子集闪亮表
【发布时间】:2014-02-21 01:16:48
【问题描述】:

我目前正在使用shinyTable,它是 HandsonTable (https://github.com/trestletech/shinyTable) 的 shiny 兼容实现。巧合的是,我意识到,如果我将 logical 列添加到呈现的 data.frame 中,值将显示为可单击的复选框。我希望用它来轻松地对表格进行子集化:

library(devtools)
# those versions are necessary to let shinyTable work with shiny
install_github( "shiny", "rstudio", ref="fcf963639e4839e5689665c257e7f488c9c34cc0" )
install_github( "shinyTable", "JackStat" )
library(shiny)
library(shinyTable)

runApp(list(
  ui = bootstrapPage( 
    htable( "tbl", clickId="tblClick", headers="provided")
  ),
  server = function(input, output) {
    output$tbl <- renderHtable({
      if( is.null( input$tbl ) ){
        return( data.frame( select = TRUE, value = 1:10  ) )
      } else{
        return( input$tbl[ input$tbl$select, ] )
      }
    })
  }
))

但是,当取消选中复选框时,我会得到以下结果:

有没有人对shinyTable 有经验,可以给我建议如何避免这种情况?

或者:

任何其他(对于我的用户舒适)让我创建子表的方法?

【问题讨论】:

  • 我使用 selectInput(...,multiple=TRUE) 进行此类子集化,对我来说似乎更整洁

标签: r shiny


【解决方案1】:

在这种情况下,少即是多

library(shiny)
library(shinyTable)

runApp(list(
  ui = bootstrapPage( 
    htable( "tbl", clickId="tblClick", headers="provided", readOnly = 'false')
  ),
  server = function(input, output) {
    output$tbl <- renderHtable({
      if( is.null( input$tbl ) ){
        return( data.frame( select = TRUE, value = 1:10  ) )
      }
    })

  }

))

【讨论】:

  • 到目前为止,谢谢,这确实避免了这种奇怪的行为。但是我现在如何进行子集化?它甚至不必是被动的。但至少必须有一个动作按钮之类的东西,它可以从视图中删除未选择的行。
猜你喜欢
  • 2014-06-28
  • 2018-06-07
  • 1970-01-01
  • 2017-08-21
  • 2021-07-08
  • 2018-02-17
  • 1970-01-01
  • 2020-08-30
相关资源
最近更新 更多