title: Unable to figure out how to create and run my user-defined R function in Shiny with input text boxes
body: <p>I've an R script for which I need to develop and intigrate a user-interface in <code>shiny</code> package in R.</p>
  
  <p>My following is a part of R code that I'm trying to build the interface around:</p>
  
  <pre><code># A random normal function to generate numbers with exact mean and SD
  rnorm2 &lt;- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
  age &lt;- rnorm2(n = 10000, mean = 55 , sd = 15)
  cholestrol &lt;- rnorm2(n = 10000, mean = 200 , sd = 30)
  bp &lt;- rnorm2(n = 10000, mean = 90 , sd = 25)
  df &lt;- cbind(age, cholestrol,bp)
  Org_Data &lt;- as.data.frame(df)
  </code></pre>
  
  <p>As there are 9 inputs (3 each for <code>age</code>, <code>cholestrol</code> and <code>bp</code>) I've created 9 input boxes in which user enters the input and then on a button click I want to run the <code>rnorm2</code> function that I created.</p>
  
  <p>My shiny app code is as follows:</p>
  
  <p>ui.R:</p>
  
  <pre><code>library(shiny)
  shinyUI(pageWithSidebar(
    headerPanel("function1"),
  
      sidebarPanel( 
        #Age input
        textInput(inputId = "n1", 
                  label = h4("Enter n for Age:"), 
                  value = ""),
  
        textInput(inputId = "mean1", 
                  label = h4("Enter mean for Age:"), 
                  value = ""),
  
        textInput(inputId = "sd1", 
                  label = h4("Enter sd for Age:"), 
                  value = ""),
  
        #Cholestrol input
        textInput(inputId = "n1", 
                  label = h4("Enter n for Cholestrol:"), 
                  value = ""),
  
        textInput(inputId = "mean1", 
                  label = h4("Enter mean for Cholestrol:"), 
                  value = ""),
  
        textInput(inputId = "sd1", 
                  label = h4("Enter sd for Cholestrol:"), 
                  value = ""),
  
  
        #Blood Pressure input
        textInput(inputId = "n1", 
                  label = h4("Enter n for Blood Pressure:"), 
                  value = ""),
  
        textInput(inputId = "mean1", 
                  label = h4("Enter mean for Blood Pressure:"), 
                  value = ""),
  
        textInput(inputId = "sd1", 
                  label = h4("Enter sd for Blood Pressure:"), 
                  value = ""),
  
  
        actionButton(inputId = "input_action", label = "Show Inputs")),
  
  
  
      mainPanel( 
        h2("Input Elements"), # title with HTML helper
        textOutput("td"))
  
  
    ))
  </code></pre>
  
  <p>But I'm completely helpless at figuring out how to put the R code I mentioned at the beginning into the <code>server.R</code> file. Can I start with simply defining the function?? And then how to run that function on those inputs taken from the user and then save the output into each of theose variables: <code>age</code>, <code>cholestrol</code> and <code>bp</code>???</p>
  
  <p>server.R:</p>
  
  <pre><code>library(shiny)
  
  #defining a function
  rnorm2 &lt;- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
  
  shinyServer(function(input, output){
  
    #Don't know how run the function and save the output into the variables 
    age &lt;- 
    cholestrol &lt;- 
    bp &lt;-  
  
  
    })
  
  })
  </code></pre>
  
  <p>This is my first day with shiny and all the server.R code samples on the internet are kinda going over my head. But I really need to turn this around today. Please help!!!</p>