shinyURL 与 updateSelectInput 的交互

Posted

技术标签:

【中文标题】shinyURL 与 updateSelectInput 的交互【英文标题】:shinyURL interaction with updateSelectInput 【发布时间】:2016-06-02 10:58:23 【问题描述】:

作为我的用户界面的一部分,用户选择一组模型参数,这些参数位于三级深度列表结构的底部。

在服务器端,我使用

observe(
    updateSelectInput(session, 'level1', choices = attributes(model[[input$toplevel]]))
)

observe(
    updateSelectInput(session, 'level2', choices = attributes(model[[input$toplevel]][[input$level1]]))
)

在 ui selectInput 部分中将 level1、level2 的选项设置为 NULL。这会将选择框更新为仅适用于之前选择的上述级别的属性。

保存的长 URL 名称确实包含选定的 level1 和 level2 选项。但是在使用时,总是只使用属性列表的顶部进行两级深顶部的***选择。

有没有聪明的方法来解决这个问题?我认为这是对 selectInput 的selected = 的一些使用,但我似乎在四处走动,无法发现服务器端所谓的 input$level1 和 input$level2 的正确语法。 谢谢

【问题讨论】:

【参考方案1】:

shinyURL 对用户输入的初始化是通过将 URL 查询字符串中的名称与 input 中的名称进行匹配来执行的。在您的应用中发生的情况是,所有selectInputs 在开始时同时由 shinyURL 设置,但此更改会触发观察者执行,从而将输入重置为其默认值。

您可以通过使用函数renderUI 动态呈现您的第 2 级和第 3 级输入来规避此问题。这将允许延迟初始化,因为 shinyURL 会等待设置输入,直到它们可用。有关此方法的说明,请参见下面的示例。

library(shiny)
library(shinyURL)

data = list(
  A = list(
    a = as.list(1:3),
    b = as.list(4:6),
    c = as.list(7:9)
  ),
  B = list(
    d = as.list(1:3),
    e = as.list(4:6),
    f = as.list(7:9)
  )
)

ui <- shinyUI(fluidPage(

   # Application title
   titlePanel("Dynamic UI"),

   # Sidebar with a slider input for number of bins 
   sidebarLayout(
      sidebarPanel(
         selectInput("toplevel", "Nested List", choices = names(data)),
         uiOutput("s1"),
         uiOutput("s2"),
         shinyURL.ui()
      ),

      mainPanel(
         h2("Selected level"),
         textOutput("selectedLevel")
      )
   )
))

server <- shinyServer(function(input, output) 
  shinyURL.server()

  output$s1 = renderUI(selectInput("lvl1",
                                   label = NULL,
                                   choices = names(data[[input$toplevel]])))
  output$s2 = renderUI(
    req(input$lvl1)
    selectInput("lvl2",
                label = NULL,
                choices = data[[input$toplevel]][[input$lvl1]])
    )

  output$selectedLevel = renderText(
    paste(input$toplevel, input$lvl1, input$lvl2, sep = " > ")
    )
)

# Run the application 
shinyApp(ui = ui, server = server)

编辑(2016 年 2 月 24 日)

renderUI动态呈现并放置在不同选项卡上的输入仅在用户切换到包含输入的选项卡时才被初始化的原因如下:呈现此类输入的outputUI界面元素是output 对象,因此在网页上隐藏时默认禁用。

解决方案是在调用outputOptions 时为每个对应的outputUI 元素设置suspendWhenHidden = FALSE 选项。

我已将 Ken O'Brien 提供的修改示例上传到 https://gist.github.com/aoles/a68892717c0280647455。它可以通过 R 运行

shiny::runGist("a68892717c0280647455")

请注意,我对原始示例进行了一些小的改进:

将对attributes() 的调用替换为names() 添加了对req() 的缺失呼叫 将id 参数添加到tabsetPanels 以允许恢复它们 将ui.Rserver.R 中的一些常用部分封装到函数中 修改了生成输入矩阵的代码

【讨论】:

谢谢。这部分有效。我的另一个复杂问题是,我还没有让这成为一个完整的解决方案,我对一些 3 级深度模型参数选择有条件(并不总是使用 - 因此不显示选择。)使用此解决方案,直到用户手动移动到选项卡在设置它的地方,条件正确,模型选择为 2 个较低级别获取 NULL。原来的observes 处理了这个 - 但正如你所说,然后在 URL 输入集调用中覆盖。 我明白了,您能否分享一个说明问题的最小工作示例?谢谢! 会的。给我一天时间,我可以得到剥离版本。谢谢。 感谢您发布详细的示例,这对指出问题非常有帮助。请参阅对我的原始答案的修改以解决您的问题。 谢谢。我只有大约一个月的 R 编码。所以你不仅解决了我的问题,看起来你整理了我一些笨拙的编码。再次感谢。【参考方案2】:

@aoles

我在这里的第一个答案是我观察的起点。在把它放在一起时,我注意到一个有趣的细节。调用的 URL -will-load level2 设置使用 topLevel 设置为属性列表的第一个值。 level3 还是错了。

GetModelParams.r 中的模型

model <- list()
#*********************************************************

#
model$savory$creamcheese$wheat$beta <- 1
model$savory$creamcheese$wheat$alpha <- 2
model$savory$creamcheese$wheat$gamma <- 3
#
model$savory$creamcheese$raisin$beta <- 4
model$savory$creamcheese$raisin$alpha <- 5
model$savory$creamcheese$raisin$gamma <- 6

#
model$savory$lox$poppy$beta <- 7
model$savory$lox$poppy$alpha <- 8
model$savory$lox$poppy$gamma <- 9

#
model$savory$lox$sesame$beta <- 8
model$savory$lox$sesame$alpha <- 7
model$savory$lox$sesame$gamma <- 6

#
model$savory$butter$poppy$beta <- 5
model$savory$butter$poppy$alpha <- 4
model$savory$butter$poppy$gamma <- 3

#
model$savory$butter$wheat$beta <- 2
model$savory$butter$wheat$alpha <- 1
model$savory$butter$wheat$gamma <- 1

#
model$salty$bacon$toasted$beta <- 2
model$salty$bacon$toasted$alpha <- 3
model$salty$bacon$toasted$gamma <- 4

#
model$salty$bacon$untoasted$beta <- 5
model$salty$bacon$untoasted$alpha <- 6
model$salty$bacon$untoasted$gamma <- 7

#
model$sweet$jelly$white$beta <- 6
model$sweet$jelly$white$alpha <- 5
model$sweet$jelly$white$gamma <- 4

#
model$sweet$jelly$muffin$beta <- 3
model$sweet$jelly$muffin$alpha <- 2
model$sweet$jelly$muffin$gamma <- 1

#
model$sweet$jam$white$beta <- 7
model$sweet$jam$white$alpha <- 11
model$sweet$jam$white$gamma <- 13

#
model$sweet$jam$muffin$beta <- 1
model$sweet$jam$muffin$alpha <- 3
model$sweet$jam$muffin$gamma <- 5

ui.R:

library(shiny)
library(shinyURL)
##############################
### ui.R #####################
##############################

source("GetModelParams.r")

topLevel <- attributes(model)

shinyUI(pageWithSidebar(

    headerPanel("URL conditional setting example"),

    sidebarPanel(
        tabsetPanel(
            tabPanel("setup",
                     radioButtons(inputId = "nTraces",
                                  label = "multiple trace, single parameter variation ",
                                  choices = list("single trace" = 1, "2 traces" = 2, "3 traces" = 3, "4 traces" = 4)),
                     selectInput(inputId = "topLev1",
                                 label = "select top Level",
                                 choices = topLevel),
                     selectInput(inputId = "secondLev1",
                                 label = "select second level",
                                 choices = NULL),
                     selectInput(inputId = "thirdLev1",
                                 label = "select third level",
                                 choices = NULL),
                     numericInput(inputId = "area1",
                                  label = "Total gate area (um^2)",
                                  min = 1, max = 10, value = 5),
                     sliderInput(inputId = "temp1",
                                 label = "Temperature (C)",
                                 min = 85, max = 125, value = 125, step = 5)
                     ),
            tabPanel("trace 2",
                     conditionalPanel(
                         condition = "input.nTraces == '2' || input.nTraces == '3' || input.nTraces == '4'",
                         radioButtons(inputId = "parVary",
                                      label = "choose single parameter variation ",
                                      choices = list("model" = "model",  "area" = "area", "temperature" = "temp")
                                      ),
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev2",
                                         label = "select top level",
                                         choices = topLevel),
                             selectInput(inputId = "secondLev2",
                                         label = "select second level",
                                         choices = NULL),
                             selectInput(inputId = "thirdLev2",
                                         label = "select third Level",
                                         choices = NULL)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area2",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp2",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
                     ),
            tabPanel("trace 3",
                     conditionalPanel(
                         condition = "input.nTraces == '3' || input.nTraces == '4'",
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev3",
                                         label = "select top level",
                                         choices = topLevel),
                             selectInput(inputId = "secondLev3",
                                         label = "select second level",
                                         choices = NULL),
                             selectInput(inputId = "thirdLev3",
                                         label = "select third level",
                                         choices = NULL)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area3",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp3",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
                     ),
            tabPanel("trace 4",
                     conditionalPanel(
                         condition = "input.nTraces == '4'",
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev4",
                                         label = "select top level",
                                         choices = topLevel),
                             selectInput(inputId = "secondLev4",
                                         label = "select second level",
                                         choices = NULL),
                             selectInput(inputId = "thirdLev4",
                                         label = "select third level",
                                         choices = NULL)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area4",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp4",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
            ),
            shinyURL.ui(tinyURL = FALSE)
        )
    ),

    mainPanel(
        tabsetPanel(
            tabPanel("Output and data type", tableOutput("textDisplay")),
            tabPanel("Model plots", plotOutput("modelPlot"))
        )
    )
))

服务器.R:

library(shiny)
library(shinyURL)
##########################################
##### server.R ###########################
##########################################

source("GetModelParams.r")

shinyServer(function(input, output, session) 
    shinyURL.server(session)
    modelCalc <- function(temp,area,model)
    
        hrs <- seq(from =0, to = 2, by = 0.05)
        F <- area*(model$alpha) + hrs*(model$beta)^3 + exp(model$gamma*(temp/100)*hrs)
        list(F = F, hrs = hrs)
    

    observe(
        updateSelectInput(session, 'thirdLev4', choices = attributes(model[[input$topLev4]][[input$secondLev4]]))
    )

    observe(
        updateSelectInput(session, 'secondLev4', choices = attributes(model[[input$topLev4]]))
    )

    observe(
        updateSelectInput(session, 'thirdLev3', choices = attributes(model[[input$topLev3]][[input$secondLev3]]))
    )

    observe(
        updateSelectInput(session, 'secondLev3', choices = attributes(model[[input$topLev3]]))
    )

    observe(
        updateSelectInput(session, 'thirdLev2', choices = attributes(model[[input$topLev2]][[input$secondLev2]]))
    )

    observe(
        updateSelectInput(session, 'secondLev2', choices = attributes(model[[input$topLev2]]))
    )

    observe(
        updateSelectInput(session, 'thirdLev1', choices = attributes(model[[input$topLev1]][[input$secondLev1]]))
    )

    observe(
        updateSelectInput(session, 'secondLev1', choices = attributes(model[[input$topLev1]]))
    )

    output$modelPlot <- renderPlot(
        temp <- lapply(paste0("temp",1:as.numeric(input$nTraces)), function(x) input[[x]])

        area <- lapply(paste0("area",1:as.numeric(input$nTraces)), function(x) input[[x]])

        modelStr <- c("topLev", "secondLev", "thirdLev")
        modelCall <- lapply(1:as.numeric(input$nTraces), function(n) paste0(modelStr,n))
        modelIn <- lapply(modelCall,function(x) model[[input[[x[1]]]]][[input[[x[2]]]]][[input[[x[3]]]]])
        mLegendStr <- lapply(modelCall, function(x) paste(input[[x[1]]],input[[x[2]]],input[[x[3]]]))

        modelOut <- list()
        if(input$nTraces == '1')
        
            modelOut <- modelCalc(area=area[[1]],temp=temp[[1]],model=modelIn[[1]])
         else
        
            modelOut <- switch(input$parVary,
                           "model" = lapply(modelIn,modelCalc,area=area[[1]],temp=temp[[1]]),
                           "temp" = lapply(temp,modelCalc,area=area[[1]],model=modelIn[[1]]),
                           "area" = lapply(area,modelCalc,temp=temp[[1]],model=modelIn[[1]])
                           )
        

        if(input$nTraces =='1')
        
            modelOut_flat <- unlist(modelOut)
         else
        
            modelOut_flat <- unlist(lapply(modelOut,unlist,recursive=FALSE))
        
        colorVec <- c('red','blue','green','cyan','magenta','black')
        F_flat <- modelOut_flat[grep("^F",names(modelOut_flat))]
        hrs_flat <- modelOut_flat[grep("^hrs",names(modelOut_flat))]
        ylim_v <- range(F_flat[F_flat>0])
        xlim_h <- range(hrs_flat[hrs_flat>0])

        if(input$nTraces == '1')
        
            plot(modelOut$hrs[modelOut$F>0],modelOut$F[modelOut$F>0],
                 log="xy",pch=1, col=colorVec[1],
                 xlab="Time [hrs]", ylab="Model output",'o',
                 ylim=ylim_v,xlim=xlim_h)
         else
        
            plot(modelOut[[1]]$hrs[modelOut[[1]]$F>0],modelOut[[1]]$F[modelOut[[1]]$F>0],
                 log="xy",pch=1, col=colorVec[1],
                 xlab="Time [hrs]",ylab="Model output",'o',
                 ylim=ylim_v,xlim=xlim_h)
        
        grid(col="blue")
        if(input$nTraces != '1')
        
            for(i in 2:length(modelOut)) 
                points(modelOut[[i]]$hrs[modelOut[[i]]$F>0],modelOut[[i]]$F[modelOut[[i]]$F>0],
                       pch=1,col=colorVec[i],'o')

            
        

        leg.names <- switch(input$parVary,
                            "temp" = sprintf('Temp=%.0f C',temp),
                            "area" = sprintf('Area=%.2e um^2',area),
                            "model"= sprintf('model=%s',mLegendStr)
                            )
        legend("topleft",leg.names,bg="white",pch=1,lty=1,col=colorVec)

        par(ps=11)
        titleRet <-  switch(input$parVary,
                            "temp" = title(sprintf("%s %s %s MODEL; Area=%.2eum^2", input$topLev1,input$secondLev1,input$thirdLev1,area[[1]])),
                            "area" = title(sprintf("%s %s %s MODEL; temp=%.0fC", input$topLev1,input$secondLev1,input$thirdLev1,temp[[1]])),
                            "model"= title(sprintf("MODEL; temp=%.0fC; Area=%.2eum^2", temp[[1]],area[[1]]))
                            )
    )

    output$textDisplay <- renderTable(
        getMat = matrix(c(input$nTraces, class(input$nTraces),
                          input$topLev1, class(input$topLev1),
                          input$secondLev1, class(input$secondLev1),
                          input$thirdLev1, class(input$thirdLev1),
                          input$temp1, class(input$temp1),
                          input$area1, class(input$area1),
                          input$topLev2, class(input$topLev2),
                          input$secondLev2, class(input$secondLev2),
                          input$thirdLev2, class(input$thirdLev2),
                          input$temp2, class(input$temp2),
                          input$area2, class(input$area2),
                          input$topLev3, class(input$topLev3),
                          input$secondLev3, class(input$secondLev3),
                          input$thirdLev3, class(input$thirdLev3),
                          input$temp3, class(input$temp3),
                          input$area3, class(input$area3),
                          input$parVary, class(input$parVary)
                          ), ncol=2, byrow = TRUE)
        colnames(getMat) = c("Value", "Class")
        getMat
    )
)

【讨论】:

【参考方案3】:

@aoles 第二个答案包含您的建议。这基本上可以作为 URL 调用 - 之后 - 用户手动逐步设置参数变化的“模型”,然后逐步通过跟踪选项卡。我希望得到一些不需要手动操作的东西。

非常感谢您的关注。

模型参数文件相同。

ui.R:

library(shiny)
library(shinyURL)
##############################
### ui.R #####################
##############################

source("GetModelParams.r")

topLevel <- attributes(model)

shinyUI(pageWithSidebar(

    headerPanel("URL conditional setting example"),

    sidebarPanel(
        tabsetPanel(
            tabPanel("setup",
                     radioButtons(inputId = "nTraces",
                                  label = "multiple trace, single parameter variation ",
                                  choices = list("single trace" = 1, "2 traces" = 2, "3 traces" = 3, "4 traces" = 4)),
                     selectInput(inputId = "topLev1",
                                 label = "select top Level",
                                 choices = topLevel),
                     uiOutput("sec1"),
                     uiOutput("thrd1"),
                     numericInput(inputId = "area1",
                                  label = "Total gate area (um^2)",
                                  min = 1, max = 10, value = 5),
                     sliderInput(inputId = "temp1",
                                 label = "Temperature (C)",
                                 min = 85, max = 125, value = 125, step = 5)
                     ),
            tabPanel("trace 2",
                     conditionalPanel(
                         condition = "input.nTraces == '2' || input.nTraces == '3' || input.nTraces == '4'",
                         radioButtons(inputId = "parVary",
                                      label = "choose single parameter variation ",
                                      choices = list("model" = "model",  "area" = "area", "temperature" = "temp")
                                      ),
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev2",
                                         label = "select top level",
                                         choices = topLevel),
                             uiOutput("sec2"),
                             uiOutput("thrd2")
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area2",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp2",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
                     ),
            tabPanel("trace 3",
                     conditionalPanel(
                         condition = "input.nTraces == '3' || input.nTraces == '4'",
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev3",
                                         label = "select top level",
                                         choices = topLevel),
                             uiOutput("sec3"),
                             uiOutput("thrd3")
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area3",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp3",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
                     ),
            tabPanel("trace 4",
                     conditionalPanel(
                         condition = "input.nTraces == '4'",
                         conditionalPanel(
                             condition = "input.parVary == 'model'",
                             selectInput(inputId = "topLev4",
                                         label = "select top level",
                                         choices = topLevel),
                             uiOutput("sec4"),
                             uiOutput("thrd4")
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'area'",
                             numericInput(inputId = "area4",
                                          label = "Total gate area (um^2)",
                                          min = 1, max = 10, value = 5)
                         ),
                         conditionalPanel(
                             condition = "input.parVary == 'temp'",
                             sliderInput(inputId = "temp4",
                                         label = "Temperature (C)",
                                         min = 85, max = 125, value = 0, step = 5)
                         )
                     )
            ),
            shinyURL.ui(tinyURL = FALSE)
        )
    ),

    mainPanel(
        tabsetPanel(
            tabPanel("Output and data type", tableOutput("textDisplay")),
            tabPanel("Model plots", plotOutput("modelPlot"))
        )
    )
))

服务器.R:

library(shiny)
library(shinyURL)
##########################################
##### server.R ###########################
##########################################

source("GetModelParams.r")

shinyServer(function(input, output, session) 
    shinyURL.server(session)
    modelCalc <- function(temp,area,model)
    
        hrs <- seq(from =0, to = 2, by = 0.05)
        F <- area*(model$alpha) + hrs*(model$beta)^3 + exp(model$gamma*(temp/100)*hrs)
        list(F = F, hrs = hrs)
    

    output$sec1 <- renderUI(
        selectInput(inputId = "secondLev1",
                    label = "select second level",
                    choices = attributes(model[[input$topLev1]])
                    )
    )

    output$thrd1 <- renderUI(
        req(input$secondLev1)
        selectInput(inputId = "thirdLev1",
                    label = "select third level",
                    choices = attributes(model[[input$topLev1]][[input$secondLev1]])
                    )
    )

    output$sec2 <- renderUI(
        selectInput(inputId = "secondLev2",
                    label = "select second level",
                    choices = attributes(model[[input$topLev2]])
                    )
    )

    output$thrd2 <- renderUI(
        selectInput(inputId = "thirdLev2",
                    label = "select third level",
                    choices = attributes(model[[input$topLev2]][[input$secondLev2]])
                    )
    )

    output$sec3 <- renderUI(
        selectInput(inputId = "secondLev3",
                    label = "select second level",
                    choices = attributes(model[[input$topLev3]])
                    )
    )

    output$thrd3 <- renderUI(
        selectInput(inputId = "thirdLev3",
                    label = "select third level",
                    choices = attributes(model[[input$topLev3]][[input$secondLev3]])
                    )
    )

    output$sec4 <- renderUI(
        selectInput(inputId = "secondLev4",
                    label = "select second level",
                    choices = attributes(model[[input$topLev4]])
                    )
    )

    output$thrd4 <- renderUI(
        selectInput(inputId = "thirdLev4",
                    label = "select third level",
                    choices = attributes(model[[input$topLev4]][[input$secondLev4]])
                    )
    )

    output$modelPlot <- renderPlot(
        temp <- lapply(paste0("temp",1:as.numeric(input$nTraces)), function(x) input[[x]])

        area <- lapply(paste0("area",1:as.numeric(input$nTraces)), function(x) input[[x]])

        modelStr <- c("topLev", "secondLev", "thirdLev")
        modelCall <- lapply(1:as.numeric(input$nTraces), function(n) paste0(modelStr,n))
        modelIn <- lapply(modelCall,function(x) model[[input[[x[1]]]]][[input[[x[2]]]]][[input[[x[3]]]]])
        mLegendStr <- lapply(modelCall, function(x) paste(input[[x[1]]],input[[x[2]]],input[[x[3]]]))

        modelOut <- list()
        if(input$nTraces == '1')
        
            modelOut <- modelCalc(area=area[[1]],temp=temp[[1]],model=modelIn[[1]])
         else
        
            modelOut <- switch(input$parVary,
                           "model" = lapply(modelIn,modelCalc,area=area[[1]],temp=temp[[1]]),
                           "temp" = lapply(temp,modelCalc,area=area[[1]],model=modelIn[[1]]),
                           "area" = lapply(area,modelCalc,temp=temp[[1]],model=modelIn[[1]])
                           )
        

        if(input$nTraces =='1')
        
            modelOut_flat <- unlist(modelOut)
         else
        
            modelOut_flat <- unlist(lapply(modelOut,unlist,recursive=FALSE))
        
        colorVec <- c('red','blue','green','cyan','magenta','black')
        F_flat <- modelOut_flat[grep("^F",names(modelOut_flat))]
        hrs_flat <- modelOut_flat[grep("^hrs",names(modelOut_flat))]
        ylim_v <- range(F_flat[F_flat>0])
        xlim_h <- range(hrs_flat[hrs_flat>0])

        if(input$nTraces == '1')
        
            plot(modelOut$hrs[modelOut$F>0],modelOut$F[modelOut$F>0],
                 log="xy",pch=1, col=colorVec[1],
                 xlab="Time [hrs]", ylab="Model output",'o',
                 ylim=ylim_v,xlim=xlim_h)
         else
        
            plot(modelOut[[1]]$hrs[modelOut[[1]]$F>0],modelOut[[1]]$F[modelOut[[1]]$F>0],
                 log="xy",pch=1, col=colorVec[1],
                 xlab="Time [hrs]",ylab="Model output",'o',
                 ylim=ylim_v,xlim=xlim_h)
        
        grid(col="blue")
        if(input$nTraces != '1')
        
            for(i in 2:length(modelOut)) 
                points(modelOut[[i]]$hrs[modelOut[[i]]$F>0],modelOut[[i]]$F[modelOut[[i]]$F>0],
                       pch=1,col=colorVec[i],'o')

            
        

        leg.names <- switch(input$parVary,
                            "temp" = sprintf('Temp=%.0f C',temp),
                            "area" = sprintf('Area=%.2e um^2',area),
                            "model"= sprintf('model=%s',mLegendStr)
                            )
        legend("topleft",leg.names,bg="white",pch=1,lty=1,col=colorVec)

        par(ps=11)
        titleRet <-  switch(input$parVary,
                            "temp" = title(sprintf("%s %s %s MODEL; Area=%.2eum^2", input$topLev1,input$secondLev1,input$thirdLev1,area[[1]])),
                            "area" = title(sprintf("%s %s %s MODEL; temp=%.0fC", input$topLev1,input$secondLev1,input$thirdLev1,temp[[1]])),
                            "model"= title(sprintf("MODEL; temp=%.0fC; Area=%.2eum^2", temp[[1]],area[[1]]))
                            )
    )

    output$textDisplay <- renderTable(
        getMat = matrix(c(input$nTraces, class(input$nTraces),
                          input$topLev1, class(input$topLev1),
                          input$secondLev1, class(input$secondLev1),
                          input$thirdLev1, class(input$thirdLev1),
                          input$temp1, class(input$temp1),
                          input$area1, class(input$area1),
                          input$topLev2, class(input$topLev2),
                          input$secondLev2, class(input$secondLev2),
                          input$thirdLev2, class(input$thirdLev2),
                          input$temp2, class(input$temp2),
                          input$area2, class(input$area2),
                          input$topLev3, class(input$topLev3),
                          input$secondLev3, class(input$secondLev3),
                          input$thirdLev3, class(input$thirdLev3),
                          input$temp3, class(input$temp3),
                          input$area3, class(input$area3),
                          input$parVary, class(input$parVary)
                          ), ncol=2, byrow = TRUE)
        colnames(getMat) = c("Value", "Class")
        getMat
    )
)

【讨论】:

以上是关于shinyURL 与 updateSelectInput 的交互的主要内容,如果未能解决你的问题,请参考以下文章

LDAP 与 MYSQL .. JA-SIG CAS 与 LDAP 与 CAS 与 MySQL

python网络编程基础(线程与进程并行与并发同步与异步)

=与==&与&&| 与 || 的区别

与 0 进行比较与与某个值进行比较是不是更快?

三.工具与市场-债券与债务股票与公司

RESTfulREST 与 RESTful 理解与实践