动作按钮闪亮

时间:2018-10-09 16:16:01

标签: r shiny

我要在Shiny中执行操作按钮。我有UI,Server和helpercode(具有所有功能)。我只想在按下按钮时转到helpercode中的函数。以下是代码:

UI-

tabPanel("Conversion", 
                           box(status = "primary", solidHeader = TRUE, 
                             collapsible = TRUE,

 shinyUI(fluidPage( 

 fluidRow(

 column(width = 6, textInput("selectnew", "Select :",value="Split"),

 actionButton("gobutton", "Start")

  ), 

  column(width = 12, offset = 0, h5(""), DT::dataTableOutput("tablenew"))

服务器-

output$tablenew = DT :: renderDataTable({
    function_new(input$selectnew)
  })

Helpercode-

function_new ()

我尝试了observerEvent和EventReactive,但无法正常工作。

1 个答案:

答案 0 :(得分:2)

这样的东西应该足以让您开始使用

library(shiny)
library(DT)

function_new <- function(x){
  as.data.frame(x)
}

ui <- fluidPage(

  fluidRow(
    column(width = 6, textInput("selectnew", "Select :",value="Split"),
           actionButton("gobutton", "Start")),
    column(width = 12, offset = 0, h5(""),dataTableOutput("tablenew"))
  )
)
server <- function(input, output, session) {

  data <- eventReactive(input$gobutton,{
    function_new(input$selectnew)
  })

  output$tablenew <- renderDataTable({
    data()
  })
}

shinyApp(ui, server)