I have a shiny app that has a lot of input values. I'd like the input values to be easily perusable and/or exportable so I'd like to put them into a table format.
Previously, I had data.table(a=input$a,b=input$b,...) but this is not a very effective way of doing things.
Aim
Present all input values in a table output in shiny without having to write each input variable by hand
Background
A shiny input object is of str:
List of 1
$ impl:Classes 'ReactiveValues', 'R6' <environment: 0xf798e60>
- attr(*, "readonly")= logi TRUE
- attr(*, "class")= chr "reactivevalues"
rbindlistresults in an error:Item 1 of list input is not a data.frame, data.table or list- Similarly
as.data.framegets:cannot coerce class ""reactivevalues"" to a data.frame - I then found
ReactiveValuesToList()which the docs say works likeas.list()but the object won't convert to insiderbindlist()
MWE
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs), col = 'darkgray', border = 'white')
})
# This is the bit I'm having trouble getting to work
output$inputvals<-renderTable({
as.data.frame(reactiveValuesToList(input))
})
}
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100)
),
mainPanel(plotOutput("distPlot"), tableOutput("inputvals"))
)
))
shinyApp(ui = ui, server = server)
shinyare you using?