0

Having issues with my data table to show up on my shiny app. Im using certain widgets in order to select key columns to display. I want to be able to select certain column values that will eventually display on my table. But as of now no table is showing up, just the widgets. What am I doing wrong?

ui <- fluidPage(
  titlePanel("Brittany's Clothes Inventory"),
  sidebarLayout(
    sidebarPanel(
 
 
   
      
      sliderInput(inputId = "Value", "1. Enter Price Range", min = 0, max = 50, value = 0.5, step = 0.01),
      
    
    
    uiOutput("picker"),
      actionButton("view", "View selection"),
    
     textOutput("DateRange")),
    
    mainPanel(ui <-
      tableOutput("table"),
      textOutput("mytext")
    )),
  
      
      
    textInput(inputId = "text", 
      label = "4. Enter Notes Here", ""),
  
  DT::dataTableOutput("table")

      ) 

server<- function(input, output, session) {

 
  output$table <- DT::renderDataTable(DT::datatable({
 
  
  observeEvent(input$reset, {
    updateSliderInput(inputId = "Price Range", value = 0)}) 
 
 
  df1
  })  
 data <- reactive({
    df1
  })  
output$picker <- renderUI({
    pickerInput(inputId = 'pick', 
                label = '3. Choose variables', 
                choices = colnames(data()),
                options = list(`actions-box` = TRUE), multiple = TRUE)
  })

 datasetInput <- eventReactive(input$view,{

    datasetInput <- data() %>% 
      select(input$pick)
    
    return(datasetInput)
})
  
# table <- reactive({(df1)})  
  
output$mytext <- renderText(input$text)
 output$table <- renderTable({table()})
}
  • First, welcome to stackoverflow! The shiny code you've posted has some nesting errors that do not allow me to run the app. Would you mind correcting those so I can reproduce what you have? Also, can you post sample data, just a few lines would be ideal. – guasi Jun 03 '22 at 15:45
  • (Almost) Never use ` – r2evans Jun 03 '22 at 16:25
  • Never nest `observe`/`reactive` within another reactive such as `renderDataTable`. (Really, I believe "never", I'm still waiting for somebody to demonstrate where nesting is good and right.) All `render*`, `observe*`, and `reactive*` functions should be at the top level of the shiny server component. – r2evans Jun 03 '22 at 16:27
  • Finally ... why do you assign to `output$table` *twice*? Your second, `output$table – r2evans Jun 03 '22 at 16:30
  • 1
    Side comment: you've allegedly taken the "welcome to SO" tour, but there appear to be two things you've missed: (1) ***Reproducibility***. See https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. (2) ***Accepting***. You have [four questions](https://stackoverflow.com/users/16951442/user16951442?tab=questions) that have reasonable answers, and you've chosen to [accept](https://stackoverflow.com/help/someone-answers) none of them. There are many benefits, one of which is that *you get points*, and eventually that'll allow you to comment and up-vote. – r2evans Jun 03 '22 at 16:34
  • 1
    Adding to @r2evans’ comment about accepting answers: it’s also *polite*, and acknowledges the effort and time that others have taken to help you. – Limey Jun 03 '22 at 17:28
  • Thanks for adding that, @Limey ... I was running low on characters and chose to be perhaps a little too terse – r2evans Jun 03 '22 at 18:02
  • Thank you everyone for the helpful comments. I will re-evaluate my work. – user16951442 Jun 04 '22 at 18:28

0 Answers0