title: How to capture R Shiny text input of variable name for analysis
body: <p>Newbie to R and working through simple R Shiny examples for learning purposes. The following program enables user to upload a delimited data file, at which point head() displays first few rows. I also want to allow use to input in a text input the name of a variable in the file to generate a frequency. How can i capture the text input and reference it in the server section?  You can see i have commented out a line where i manually enter the field and it works fine.</p>
  
  <p>I've sifted through quite a few examples using textinput, but all were facing different issues than i could find. I do apologize if a post already has the help i seek.  Thanks in advance.</p>
  
  <pre><code>server &lt;- function(input, output) {
  
    splay &lt;- reactive({
  
      req(input$file1)
  
      df.raw &lt;- read.csv(input$file1$datapath, header = input$header, sep = input$sep, quote = input$quote)
  
      info &lt;- list(df.raw=df.raw)
      return(info)
     })
  
    output$contents &lt;- renderTable({
      if(input$disp == "head") { return(head(splay()$df.raw)) }
      else { return(splay()$df.raw) }
     })
  
    observe({
        varname &lt;- renderText({input$frqvar})
    })
  
    output$jason &lt;- renderTable({
      if (is.null(input$file1)) { return() }
      #table(splay()$df.raw$tx)
      table(splay()$df.raw$varname())
    })
  
    output$caption1 &lt;- renderText({
      if (is.null(input$file1)) { return() }
      paste("Listing of Uploaded Data and Frequency of ",input$frqvar ,"Variable")
    })
  
  } #this ends the server function
  
  #ui=user interface portion
  #place elements in the fluid page section to layout the page
  ui &lt;- fluidPage(
  
    # App title
    titlePanel("Uploading Files"),
  
    # Sidebar layout with input and output definitions
    sidebarLayout(
  
      # Sidebar panel for inputs
      sidebarPanel(
  
        # Input: Select a file
        fileInput("file1", "Choose CSV File", multiple = FALSE, accept = c("text/csv", "text/comma-separated-values,text/plain", ".csv")),
  
        # Horizontal line
        tags$hr(),
  
        # Input: Checkbox if file has header 
        checkboxInput("header", "Header", TRUE),
  
        # Input: Select separator 
        radioButtons("sep", "Separator",
                     choices = c(Comma = ",",
                                 Semicolon = ";",
                                 Tab = "\t"),
                     selected = ","),
  
        # Input: Select quotes 
        radioButtons("quote", "Quote",
                     choices = c(None = "",
                                 "Double Quote" = '"',
                                 "Single Quote" = "'"),
                     selected = '"'),
  
        # Horizontal line 
        tags$hr(),
  
        # Input: Select number of rows to display 
        radioButtons("disp", "Display",
                     choices = c(Head = "head",
                                 All = "all"),
                     selected = "head"),
  
        textInput("frqvar", 
                     label = h1("Variable to run Freq"), 
                     value = " " ),
        actionButton("action", label="Submit")
     ),
  
      # Main panel for displaying outputs ----
      mainPanel(
  
        # Output: Data file ----
        textOutput("caption1"),
        tableOutput("contents"),
        tableOutput("jason")
  
        #tableOutput("")
        )
      )
  )
  
  shinyApp(ui = ui, server=server)
  </code></pre>