title: R: Writing reactive output to an excel file?
body: <p>I am creating a method in R that takes in 4 values from a survey and then saves them to local variables and places them in a matrix, it then writes that matrix to an excel file. Pretty simple concept, however since the input is reactive.. if more than one survey is entered then it just overwrites the previous survey.. so now I need a counter variable. Here is some clips of the code. </p>
  
  <p>(In the server class)</p>
  
  <pre><code>  surveyFinish &lt;- eventReactive(input$click2,{``
    state = input$UState
    happiness = input$UHap
    work = input$UWork
    env = input$UEnv
    surveyans &lt;- paste(state, happiness, work, env, sep=" ")
  
    newMat = matrix(
      c(state, env, work, happiness),
      nrow = 1,
      ncol = 4,
      byrow = TRUE)
  
    writeWorksheetToFile("StateSurvey.xlsx", newMat, "SomeOtherSheet", z, 1, header = FALSE)
    write.table(newMat, "SurveyTab.txt", sep="\t")
  
  
  
    return()
  })
  
   output$youSaid&lt;- renderDataTable({
    surveyFinish()
  })
  </code></pre>
  
  <p>(In the UI)</p>
  
  <pre><code>tabPanel("Survey",
                    textInput("UState", label = h2("Your State"), 
                              value = "State name"),
                    numericInput("UHap", label = h2("Your Happiness"), 
                              value = "Enter a number from 1-10", min = 1, max = 10),
                    numericInput("UEnv", label = h2("Your Environment"), 
                                 value = "Enter a number from 1-10", min = 1, max = 10),
                    numericInput("UWork", label = h2("Your Workload"), 
                                 value = "Enter a number from 1-10", min = 1, max = 10),
                    actionButton("click2", "Finish Survey!"),
  
                    tableOutput("youSaid")
  
  
           ),
  </code></pre>