我可以在R Shiny中有多个提交按钮吗? [英] Can I have multiple submit buttons in R shiny?

查看:449
本文介绍了我可以在R Shiny中有多个提交按钮吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的R Shiny应用程序中,我想要一个按钮来提交一组输入(影响输出的一部分),而另一个按钮来提交其余输入(影响输出的不同部分). Shiny教程的小部件示例中的代码使用了commitButton,但是当按下单个按钮时,似乎所有输入都已交付?预先感谢您的帮助.

In my R shiny application, I would like to have one button to submit one set of inputs (which affect one portion of the output) and another one to submit the remaining inputs (which affect a different portion of the output). The code in the widgets example of the Shiny tutorial uses a submitButton but it seems like all the inputs are delivered when that single button is pressed? Thanks in advance for your help.

推荐答案

以下是显示actionButtons控制电抗性组件的示例:

Here is an example showing actionButtons controlling reactive components:

library(shiny)
runApp(list(
  ui = fluidPage(
    titlePanel("Hello Shiny!"),
    sidebarLayout(
      sidebarPanel(
        tags$form(
          numericInput('n', 'Number of obs', 100)
          , br()
          , actionButton("button1", "Action 1")
        )
        , tags$form(
          textInput("text", "enter some text", value= "some text")
          , br()
          , actionButton("button2", "Action 2")
        )
      ),
      mainPanel(
        plotOutput('plot')
        , textOutput("stext")
      )
    )
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ 
      input$button1
      hist(runif(isolate(input$n))) 
    })
    output$stext <- renderText({
      input$button2
      isolate(input$text )
    })
  }
)
)

这篇关于我可以在R Shiny中有多个提交按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆