satheesh perepu
satheesh perepu

Reputation: 13

R shiny radio button

I a new to R shiny and building an application in R shiny. I want to present a table with two different outputs based on the out1 variable. For that, I wrote

output$inputs <- renderDataTable({
    if((input$O1 == 'Max_profit'))
    inpts()
  })
  output$inputs <- renderDataTable({
    if (( inputs$O1 == 'Optimum_profit'))
    inpts1()
  })

When I press the action button in UI, I cannot see any output in UI. It is showing object inputs not found.

I searched the internet but could not find anything. Please, help me in this.

Upvotes: 1

Views: 414

Answers (1)

Pork Chop
Pork Chop

Reputation: 29407

You have 2 divs with the same name. You either rename them, or wrap your if statement into a reactive or take all the conditions into one expression:

output$inputs <- renderDataTable({
        if(is.null(nput$O1)){
                return()
        }
        if(input$O1 == 'Max_profit'){
                inpts()
        }
        if(inputs$O1 == 'Optimum_profit'){
                inpts1()
        }
})

Upvotes: 1

Related Questions