in app.R in server function
server <- function(input, output) {
I have this reactive function which checks the radiobutton input and populates the input choice in select input.
var <- reactive({
switch(input$selectBy,
"cname" = customers[,1],
"cloan_num" = customers[,2]
)
})
Now I wanted to change the label in the selectInput function based on radio button but I am not able to do so.
ifelse(input$selectBy == "cname", lbText = "Select Customer Name", lbText = "Select Loan AC Number" )
in the above line I am getting
Error in ifelse(input$selectBy == "cname", lbText = "Select Customer Name", : unused arguments (lbText = "Select Customer Name", lbText = "Select Loan AC Number")
output$selInp <- renderUI({
selectInput("noc",lbText, var(), selected = NULL, multiple = FALSE,
selectize = TRUE, width = NULL, size = NULL)
})
Full Code:
ui=fluidPage(
titlePanel("Title"),
sidebarLayout(position = "left",
sidebarPanel(
fluidRow(
uiOutput("selInp"),
radioButtons("selectBy", "Search By:",
c("Customer Name" = "cname",
"Customer Loan No" = "cloan_num")),
pickerInput("branch","Branch", choices=unique(customers[,4]), options = list(`actions-box` = TRUE),multiple = T),
dateInput("endDate", "End Date:", value = "2018-12-30")
)
),
mainPanel()
)
)
########################## server function ################################
server <- function(input, output) {
var <- reactive({
switch(input$selectBy,
"cname" = customers[,1],
"cloan_num" = customers[,2]
)
})
ifelse(input$selectBy == "cname", lbText = "Select Customer Name", lbText = "Select Loan AC Number" )
output$selInp <- renderUI({
selectInput("noc",lbText, var(), selected = NULL, multiple = FALSE,
selectize = TRUE, width = NULL, size = NULL)
})
}
shinyApp(ui, server)
Aucun commentaire:
Enregistrer un commentaire