Dynamic table using database and Shiny

Asked

Viewed 222 times

2

I’m creating a dynamic table using Shiny, but I have some questions:

1° how to integrate the column name of my database into a selectInput() so that only selected variables appear in the table and update automatically as I select or remove variables from the box generated by selectInput?

2° Tenhoum sliderInput() which I would like to be used as a one-column filter, for example, if the slider were ticking the value 100 the dataframe lines would be displayed where that particular column would only display values equal to or less than 100, it is possible to make this connection?

3° renderDataTable limits me to only 100 lines displayed at most, would remove this limitation?

I’m open to modifications that might make this visualization look better

Follow my code so far:

ui <- fluidPage( 

  titlePanel("EPE"),
  sidebarLayout(

    sidebarPanel(
      #Todos os indicadores da tabela são selecionáveis
      selectInput('epe',"Escolha os indicadores", lista(EPE), multiple = TRUE),
      textOutput("resultado"),
      sliderInput('slider',"Intervalo",min = 0, max = 9000,value = 10) ),

    mainPanel(  
      h1('Tabela'),
      fluidRow( column( width = 4)),
      DT::dataTableOutput('tab') )       
 )
)

server <- function(input,output){

  #Testar o bom funcionamento do código por enquanto

  output$resultado <- renderText({paste(" ", input$epe)})

  output$tab <- DT::renderDataTable({EPE})   
}

1 answer

1

Answering the first and third question:

UI

                conditionalPanel(
                  'input.dataset === "EPE"',
                  checkboxGroupInput("show_vars", "Selecione as variáveis:",
                                     names(EPE), selected = names(EPE))),
                mainPanel(
                  tabsetPanel(
                    id = 'dataset',
                    tabPanel("EPE", DT::dataTableOutput("mytable1"))
                  ), width = 12
                ),
                dataTableOutput("EPEtable")



Server


    output$mytable1 <- DT::renderDataTable({
      DT::datatable(EPE[, input$show_vars, drop = FALSE], options = list(pageLength = -1))
    })

options = list(pageLength = -1) removes the line limit.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.