我想在Shiny应用程序中显示和编辑rhandsontable
。由于我的数据框相当大,我希望用户能够过滤特定的行而不是显示整个1000行(请参见下面的示例)。我可以基于input$row
为子集hot
创建一个反应值,但只有DF[input$row,]
被分配给input$hot
,因此,下一次我得到input$hot
的值时,它将返回一个只有一行的数据帧。在R中过滤rhandsontable中的行Shiny
library(shiny)
library(rhandsontable)
ui <- shinyUI(fluidPage(
numericInput("rows","row to filter",value = 1),
rHandsontableOutput("hot")
))
server <- shinyServer(function(input, output, session) {
# render handsontable output
output$hot <- renderRHandsontable({
if (!is.null(input$hot)) {
DF <- hot_to_r(input$hot)
} else {
set.seed(42)
DF <- data.frame(a=1:1000, b= rnorm(1000))
}
rhandsontable(DF)
})
})
runApp(list(ui=ui, server=server))
是否有一个过滤paramenter,我可以适用于rhandsontable()
,让我来呈现我的数据帧的过滤版本,而无需实际子集划分它,以使关联input$hot
将不受影响(除中,当然,对于用户所做的任何编辑)?
我希望用户在textInput框row
中写入要过滤的行,然后相应地过滤表。当务之急是nrow(hot_to_r(input$hot)) == 1000
仍然是TRUE:
什么你的意思是“没有子集的过滤版本”?你想渲染什么? –
@StéphaneLaurent,增加了预期的渲染。我遇到的问题是,如果我选择通过类似'DF [rows,]'的子集(当然是反应性的方式),那么子集DF将被保存回'input $ hot',行。 –