Hi all,
Not sure what wrong I am doing here. Since the length(key) is 0, I need to assign the value of selectedInput
to key_as
. If the length(key) is not 0, then key_as
should be "a"
ui.R
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
uiOutput("edit_condition")
)
)
))
server.R
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
columnNames <- c("A","B","C")
key <- c()
key_1 <- c("a")
# print(length(key))
if(length(key) == 0){
output$edit_condition <- renderUI({
selectInput("ed", "Condition", choices = c(columnNames), selected = columnNames[[1]])
})
key_as <- input$ed
} else {
key_as <- key_1
}
print(key_as)
})