I have the shiny dashboard below in which I select from the pickerInput()
"Select Database/s"
if I will display the values of either Sepal.Length
if only this is selected or Sepal.Width
if only this is selected or both if both selected. Is it possible to achieve it inside the same uiOutput("fnamesid")
and without having to use 2 different uiOutput()
?
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
header = dashboardHeader(title = "My dashboard"),
sidebar = dashboardSidebar(
uiOutput("dbs"),
uiOutput("fnamesid")
),
body = dashboardBody(
)
)
server <- function(input, output, session) {
output$dbs<-renderUI({
pickerInput("DB", "Select Database/s",
choices = c("Sepal.Length","Sepal.Width"),
multiple = T,options = list(`actions-box` = TRUE),
selected = "Sepal.Length")
})
output$fnamesid<-renderUI({
if("Sepal.Length"%in% input$DB){
pickerInput("sn", "Select sn_ID for x-axis",
choices = unique(iris$Sepal.Length),
multiple = T,options = list(`actions-box` = TRUE),
selected = head(unique(iris$Sepal.Length)))
}
else if("Sepal.Width"%in% input$DB){
pickerInput("sn2", "Select sn_ID for x-axis",
choices = unique(iris$Sepal.Width),
multiple = T,options = list(`actions-box` = TRUE),
selected = head(unique(iris$Sepal.Width)))
}
else if("Sepal.Length"%in% input$DB&"Sepal.Width"%in% input$DB){
pickerInput("sn", "Select sn_ID for x-axis",
choices = unique(iris$Sepal.Length),
multiple = T,options = list(`actions-box` = TRUE),
selected = head(unique(iris$Sepal.Length)))
pickerInput("sn2", "Select sn_ID for x-axis",
choices = unique(iris$Sepal.Width),
multiple = T,options = list(`actions-box` = TRUE),
selected = head(unique(iris$Sepal.Width)))
}
})
}
shinyApp(ui, server)