【发布时间】:2017-08-30 15:46:52
【问题描述】:
我正在尝试构建一个闪亮的应用程序。在我的代码中,我使用如下条件面板,用户可以在不同的input.pkmodel 之间进行选择,并根据不同的参数集向用户显示
library("shiny")
ui <- fluidPage(theme = shinytheme("united"),
actionButton("go", "RUN"),
selectInput("PKmodel",
"Select the PK Model:",
choices = list(" 1 Compartment Model" = 1,
" 2 Compartment Model" = 2),
selected = 1),
conditionalPanel(
condition = "input.PKmodel == 1",
numericInput("CL", "CL:", 5, min = 0.000001, max = 10000,step = .01)
),
conditionalPanel(
condition = "input.PKmodel == 2",
numericInput("CL", "CL:", 20, min = 0.000001, max = 10000,step = .01),
numericInput("VC", "V:", 13, min = 0.0000001, max = 20,step = .01))
)
server <- function(input, output) {
sim.data <- eventReactive(input$go,{
selectPKmod <- input$PKmodel
if (selectPKmod == 1) {
CLIN<-input$CL }
if (selectPKmod == 2) {
CLIN<-input$CL
VCIN<- input$VC }
} )
}
shinyApp(ui = ui, server = server)
我正面临这个问题: 当我选择 input.PKmodel == 2 时,CL 参数值既不会更改为 20“input.PKmodel == 2 的默认值”,也不会更改为任何用户定义的值。但相反,它保持为 CLIN=5 "the default for input.PKmodel == 1" 。
换句话说,如果我选择 input.PKmodel == 2,然后“使用用户界面”更改了 VCIN 或 CLIN 的值,这些值都不会改变。 对于 CLIN,它保持固定在 5 的值(从默认值 input.PKmodel == 1), 并且 VCIN 参数保持固定为 13 的值(来自 input.PKmodel == 2)。所以似乎参数获得了它们第一次出现的值,但它们没有得到更新。 你能帮忙解决这个问题吗?另外,请注意我正在使用 actionButton 和 eventReactive (我不确定这是否与问题有关)。 谢谢
【问题讨论】: