title: Create a dynamic dataframe based on user’s inputs in R Shiny UI
body: <p>I am running a regression model using an available training dataset, say 1000 observations and 5 independent variables.</p>
  
  <p>Now I want to run this model against a test dataset. So I am trying to fetch test dataset manually from user on Shiny UI.
  User should have an option to select number of observations in test dataset, for e.g. 50 observations.
  Once the user provides number of observations, user should be able to view a table of 50 rows and independent variables (or any other view).
  User should now be able to enter arbitrary values manually in these 50 rows for each independent variable on Shiny UI.</p>
  
  <p>Currently, I am able to fetch only 1 observation from user for each variable after running below code for UI.</p>
  
  <p>Code:</p>
  
  <pre><code>library(shiny)
  
  
  
    ui&lt;-shinyUI(fluidPage(
      titlePanel("Model"),
  
  
      sidebarLayout(
        sidebarPanel(
        sliderInput("Var1",label="Variable 1",min=100,max=1000,value=200,step=1),
        sliderInput("Var2",label="Variable 2",min=500,max=800,value=600,step=1),
        sliderInput("Var3",label="Variable 3",min=0,max=1,value=0.5,step=0.01),
        sliderInput("Var4",label="Variable 4",min=1,max=20,value=5,step=1),
        sliderInput("Var5",label="Variable 5",min=0,max=1,value=0.6,step=0.01),
        actionButton("Run_model", "Run model")
        ),
  
        mainPanel(
  
          tabsetPanel(
          tabPanel("model summary", verbatimTextOutput('summary'))
          )
        )
      )))
  
  
    server&lt;- function(input,output,session){
      set.seed(1234)
      observe({
        # this is how you fetch the input variables from ui component
  
        Var1 &lt;- as.integer(input$Var1)
        Var2 &lt;- as.integer(input$Var2)
        Var3 &lt;- as.numeric(input$Var3)
        Var4 &lt;- as.integer(input$Var4)
        Var5 &lt;- as.numeric(input$Var4)
  
        test &lt;- cbind(Var1, Var2, Var3, Var4, Var5)
        test &lt;- as.data.frame(test)
  
        ## Import dataset
        train &lt;- data.frame(replicate(6,sample(1:100,1000,rep=TRUE)))
        names(train) &lt;- c("Var1", "Var2", "Var3", "Var4", "Var5", "Var6")
  
        # Var6 is the dependent variable
        test$Var6 &lt;- ""
  
        # Model action button
        observeEvent(input$Run_model, {
          model &lt;- randomForest(Var6 ~ .,  data = train, ntree=500)
          pred &lt;- predict(model, newdata = test)
          output$summary &lt;- renderPrint(model)
  
        })
      })
    }
  
  shinyApp(ui=ui, server=server)
  </code></pre>