I have a pickerInput with three variables and I want when I select a variable I can set the mean and sd for each variable.
Then I am using these values to compute their distributions.
The problem is that this code sets mean and sd only to the first variable that I select.
Thank you in advance!
Here is a part of my code:
library(shiny)
library(shinyWidgets)
ui <-
fluidPage(
#3variables are g, m, c
checkboxInput("checkbox", label = "Use priors"),
uiOutput("conditionalInput"),
conditionalPanel(
condition = "input.priors == 'g'",
numericInput("mg", "Mean:", NULL, min = 0, max = 1000000),
numericInput("sdg", "Sd:", NULL , min = 0, max = 1000000)
),
conditionalPanel(
condition = "input.priors == 'm'",
numericInput("mm", "Mean:", NULL, min = 0, max =
1000000),
numericInput("sdm", "Sd:", NULL, min = 0, max = 1000000)
),
conditionalPanel(
condition = "input.priors == 'c'",
numericInput("mc", "Mean:", NULL, min = 0, max = 1000000),
numericInput("sdc", "Sd:", NULL, min = 0, max = 1000000)
)
)
server <- function(input, output, session) {
output$conditionalInput <- renderUI({
if (input$checkbox == TRUE) {
pickerInput("priors",
"Select priors",
c(
"r" = "g",
"m" = "m",
"K" = "c"
),
multiple = T)
}
})
}
shinyApp(ui = ui, server = server)
Here is another solution with
(input.priors.indexOf('g') > -1) & input.checkbox == '1'
as condition. In addition putting thepickerInput
into aconditionalPanel
thenumericInputs
won't show when starting the app.EDIT: Answer to @YBS question - If pickerInput needs to be on the server side for processing user supplied dataset, can you make the numericInputs not show up when starting the app?
I copied the conditionalPanel including the pickerInput into the server. Seems still to hide the numericInputs.