I want to display and edit an rhandsontable
within a Shiny app. Since my data frame is fairly large, I want the user to be able to filter a specific row instead of displaying the whole 1000 rows (see example below). I can create a reactive value to subset hot
based on input$row
, but then only DF[input$row,]
is assigned to input$hot
and, thus, next time I get the value of input$hot
it returns a data frame with only one row.
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))
Is there a filtering paramenter that I can apply to rhandsontable()
that would allow me to render a filtered version of my data frame without actually subsetting it, so that the linked input$hot
wouldn't be affected (except, of course, for any edits made by the user)?
I want the user to write the row to filter in the textInput box row
and then the table to be filtered accordingly. It is imperative that nrow(hot_to_r(input$hot)) == 1000
continues to be TRUE: