6

Hi I want to create a shiny UI which a user can type in the name of a data-set into a text box say "testdataset". Then by clicking and action button to select a particular process in this (example) analysis 1 or analysis 2. Once this happens I want the text box to show the original data-set name plus the analysis chosen ie "testdataset-analysis1" . I've built and example UI below but Im new to R and shiny and dont know how to capture the events and pass the variables between the UI and the server and render them. can anyone help? example of what i would like to achieve
library(shiny)

  #====shiny UI
  shinyUI(pageWithSidebar(
    headerPanel("Shiny action button input "),
    sidebarPanel(
      textInput(inputId="data1", label = "Input data name"),

      actionButton("Ana1", "analysis1"),
      actionButton("Ana2", "analysis2")
    ),
    mainPanel(
  #
    )
  ))

  #====shiny server
  shinyServer(
    function(input, output) {
      output$data1 <- renderText({input$data1})

    })
  }
  )

  runApp()#to run application
user5300810
  • 61
  • 1
  • 3

1 Answers1

7

This is not a complete answer, but it is good to try for yourself. In general, use updateTextInput to update the text, use observeEvent to observe the click action on a button, use input$name to catch input values, and use output$name <- render... to set output. There are several updateInput methods that you can find in the official Shiny reference. http://shiny.rstudio.com/reference/shiny/latest/

For example, in your server code

function(session, input, output) {
    observeEvent(input$Ana1, {
        name <- paste(input$data1, "analysis 1")
        updateTextInput(session, "data1", value=name)
    }
}
Xiongbing Jin
  • 11,779
  • 3
  • 47
  • 41