Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的操作按钮和selectInput:单击操作按钮后,将selectInput的输入传递给函数_R_Shiny_Igraph_Shinyjs_Shinyapps - Fatal编程技术网

R中的操作按钮和selectInput:单击操作按钮后,将selectInput的输入传递给函数

R中的操作按钮和selectInput:单击操作按钮后,将selectInput的输入传递给函数,r,shiny,igraph,shinyjs,shinyapps,R,Shiny,Igraph,Shinyjs,Shinyapps,我有一个关于R的问题 我在global.R中定义了一个函数,它接受3个参数,然后显示一个绘图,因此: get.plot(mode, threshold, names = names) 在我闪亮的应用程序中,我设置了一个侧栏面板,其中模式为selectInput(multiple=FALSE),名称为selectInput(multiple=TRUE),阈值为sliderInput。在我的ShinyApp的主面板中,我使用两个selectInput对象和sliderInput的输入动态渲染绘图,

我有一个关于R的问题

我在global.R中定义了一个函数,它接受3个参数,然后显示一个绘图,因此:

get.plot(mode, threshold, names = names)
在我闪亮的应用程序中,我设置了一个侧栏面板,其中模式为selectInput(multiple=FALSE),名称为selectInput(multiple=TRUE),阈值为sliderInput。在我的ShinyApp的主面板中,我使用两个selectInput对象和sliderInput的输入动态渲染绘图,这两个对象工作得非常好

“我的函数”中的“名称”列表包含10个不同的名称(所有名称均以默认设置显示),可以使用selectInput(multiple=FALSE)以任何方式组合这些名称。问题是我的函数很长,计算时间也很长,因为每次我在selectInput中删除一个名称时,它都会重新计算函数。例如,如果我只想显示2个名称,我必须删除selectInput的8个名称,这意味着函数要重新计算8次,这需要很长时间

我想显示一个操作按钮(“应用名称”),在选择名称后可以单击该按钮。但是,我仍然希望绘图动态调整到其他参数模式和阈值,并且按钮应该只更改names参数

你知道我怎么解决这个问题吗?或者你还有其他建议吗

我的设置大致如下所示:

ui <- fluidPage(

  sidebarLayout(
    sidebarPanel(
      selectInput(inputId = "network_names",
                  label = "Select multiple names",
                  choices = names,
                  multiple = TRUE,
                  selected = names
      ),

      selectInput(inputId = "network_mode",
                  label = "Select a mode",
                  choices = list("Mode 1",
                                 "Mode 2")
      ),

      sliderInput(inputId = "threshold",
                  label = "Threshold",
                  min = 1,
                  max = 10,
                  value = 3)
)


server <- function(input, output){

output$network <- renderPlot({
  if(input$network_mode == "Mode 1") {

    get.plot(1, input$threshold, names = input$network_names)

  } else if(input$network_mode == "Mode 2") {

    get.plot(2, input$threshold, names = input$network_names)
  }
})
}
ui尝试隔离()函数。尝试使用isolate()函数。