我在 R 中闪亮的服务器中遇到反应输出问题。
我想要做的是创建一个使用基于输入计算的值的绘图。
仅在单击提交/完成按钮后才必须更新输出,并且必须根据需要多次计算输出。
我设法做的是独立于提交按钮更新内容(提交按钮根本没有功能),并且在我更改 1 个值后立即更改了绘图。
我想要做的是仅在指定我想要的所有参数值后更改绘图。
这是我的 ui.R 代码的最小示例:
shinyUI(fluidPage(
titlePanel("Wages in Year 2016 for Czech Republic in CZK"),
sidebarPanel(
conditionalPanel(condition = "input.conditionedPanels==7",
selectInput("Age", "Age", choices = vek_mod$Vek, selected = "23-27"),
selectInput("ChosenSex", "Your sex", choices = pohlavi_mod$Pohlavie, selected = "Zena"),
actionButton("Button", "Done"),
p("Click so changes will take effect.")
),
mainPanel(
tabsetPanel(
...
tabPanel("Minimal_Example", textOutput("Minimal_Example"), value = 7)
...
, id = "conditionedPanels"
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
这是 server.R 代码:
...
output$Minimal_Example <- renderPrint({
Age <- input$Age
Sex <- input$ChosenSex
c(Age, Sex)
})
...
Run Code Online (Sandbox Code Playgroud)
我用observeEvent() 和eventReactive() 尝试了很多东西,但到目前为止没有任何效果对我有用。
如果您想查看代码的行为方式,请看这里:http: //52.59.160.3 : 3838/sample-apps/Mzdy_ShinyApp/
Tab 被称为 Minimal_Example
谢谢
submitButton 就是为此而生的。
如果您想actionButton改用,只需使用isolate避免基于值更改的刷新,并input$Button在代码中添加如下:
output$Minimal_Example <- renderPrint({
input$Button
Age <- isolate(input$Age)
Sex <- isolate(input$ChosenSex)
c(Age, Sex)
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2947 次 |
| 最近记录: |