我有一个带有三个变量的pickerInput,当我选择一个变量时,我可以为每个变量设置平均值和标准差。
然后我使用这些值来计算它们的分布。
问题是此代码仅将 mean 和 sd 设置为我选择的第一个变量。
先感谢您!
这是我的代码的一部分:
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)