我有一个带有大量参数的应用程序。每个参数都有很多粒度,这使得找到所需的参数变得很痛苦。这会导致反应部分不断计算,从而减慢速度。我添加了一个提交按钮,它解决了上述问题,但随后又遇到了另一个问题。
下面是我构建的框架的简单复制。参数输入接受1到1000之间的数字,这表示我想要的样本。我想做的是能够执行上述操作,但也能够使用同一组参数重新采样。添加提交按钮后现在发生的情况是,除非我先单击重新采样然后更新按钮,否则它会使重新采样按钮无法操作。
有什么想法可以让它们分开工作吗?
shinyServer(function(input, output) {
getY<-reactive({
a<-input$goButton
x<-rnorm(input$num)
return(x)
})
output$temp <-renderPlot({
plot(getY())
}, height = 400, width = 400)
})
shinyUI(pageWithSidebar(
headerPanel("Example"),
sidebarPanel(
sliderInput("num",
"Number of Samples",
min = 2,
max = 1000,
value = 100),
actionButton("goButton", "Resample"),
submitButton("Update View")
),
mainPanel(
tabsetPanel(
tabPanel("Heatmap",
plotOutput("temp")
),
tabPanel("About"),
id="tabs"
)#tabsetPanel
)#mainPane;
))
根据乔的回答进行编辑:
shinyServer(function(input, output) {
getY<-reactive({
isolate({a<-input$goButton
x<-rnorm(input$num)
return(x)})
})
output$temp <-renderPlot({
b<-input$goButton1
plot(getY())
}, height = 400, width = 400)
})
shinyUI(pageWithSidebar(
headerPanel("Example"),
sidebarPanel(
sliderInput("num",
"Number of Samples",
min = 2,
max = 1000,
value = 100),
actionButton("goButton", "Resample"),
actionButton("goButton1","Update View")
),
mainPanel(
tabsetPanel(
tabPanel("Heatmap",
plotOutput("temp")
),
tabPanel("About"),
id="tabs"
)#tabsetPanel
)#mainPane;
))