Hello everybody. I'm having trouble with my shiny app and I have been stuck in this for several hours.
My app is supposed to take a data frame and display a table of the data frame, and a plot of some of the information contained in the data frame. The plot is created through a function I designed which receives as input the data frame. Which data frame that is going to be ploted or printed is selected by the user with a selectInput. The select input looks like this:
selectInput(inputId = "bank", label= "Choose the bank to analyse",
choices = c("Bank One" = "bank1",
"Bank Two" = "bank2",
"Bank Three" = "bank3"),
selected = "bank1"),
I have many banks and for each bank I generate a data frame named bank1, bank2 and so on. The data frames are created after some burdensome calculations I put in the server function. I'm creating a data frame named data as a reactive like this:
data <- reactive({ input$bank})
And then it is supposed to display the data frame with the following code chunk:
output$table1 <- DT::renderDataTable({
DT::datatable(data(), options = list(pageLength=6)))
})
The code as shown generates the following Error message: 'data' must be 2-dimensional (e.g. data frame or matrix).
The app is actually generating the data frames becouse if, for example, I replace the input$bank with bank1 the data frame is displayed correctly. So, the data frames not existing is not the problem.
The problem, I believe, is that somehow shiny is reading the input as character and not as a data frame, even though the data frame exists. But so far I do not know why this is happening and how to solve it. I'd really appreciate your help.
I do not provide the whole app becouse it is too large.