title: How to fix - Object "Inputs2' not found. And get the final plot in R Shiny
body: <p>I am new to building apps in RStudio Shiny. I have checked everything in my following code and it seems to be working all the way up to plotting, however I can't get any plot and the server window gives an error: "Object 'Inputs2' not found." Any help will be appreciated with the code. And my final goal is to get the plot.</p>
  
  <pre><code>library(shiny)
  library(Benchmarking)
  library(plotly)
  
  # load data 
  maindata &lt;- read.csv("raw.csv", stringsAsFactors = FALSE)
  
  
  # Define UI for application 
  ui &lt;- fluidPage(theme = "bootstrap.css",
  
  
  # Application title
  titlePanel("Preferred Usage"),
  
  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      h3("Enter Inputs",""),
      numericInput("qout1", "Output 1","0"),
      numericInput("qout2", "Output 2","0"),
      numericInput("qin1", "Input 1","0"),
      numericInput("qin2", "Input 2","0"),
      numericInput("qin3", "Input 3","0"),
      numericInput("pin1", "Price Input 1","0"),
      numericInput("pin2", "Price Input 2","0"),
      numericInput("pin3", "Price Input 3","0"),
      actionButton("runButton", "Run Analysis")
  
  
    ),
  
    # Show a plot of the generated distribution
    mainPanel(
       plotOutput("coolplot")
  
     )
   )
  )
  </code></pre>
  
  <p>An the server side code:</p>
  
  <pre><code>server &lt;- function(input, output) {
  
  
  # The important part of reactiveValues()
  values &lt;- reactiveValues()
  grph &lt;- reactiveValues()
  values$df &lt;- maindata 
  addData &lt;- observe({
  
  # your action button condition
  if(input$runButton &gt; 0) {
    # create the new line to be added from your inputs
    newLine &lt;- isolate(c(input$qout1, input$qout2, input$qin1, input$qin2, input$qin3, input$pin1, input$pin2, input$pin3))
    # update your data
    # note the unlist of newLine, this prevents a bothersome warning message that the rbind will return regarding rownames because of using isolate.
    table1 &lt;- isolate(values$df &lt;- rbind(unlist(newLine), as.matrix(values$df)))
  
  
  
    # inputs and outputs for analysis
    y &lt;- data.frame(table1[, 1:2])
    x &lt;- data.frame(table1[, 3:5])
    w &lt;- data.frame(table1[, 6:8])
  
  
  
    # function to do some analysis
    xopt &lt;- cost.opt(x, y, w, RTS=1)
  
    # Fetch results
    results &lt;- data.frame(xopt[["xopt"]])
    results[1,]
  
    #Prepare data for plotting 
    Inputs &lt;- c("Seed", "Fertilizer", "Power")
    Inputs2 &lt;- as.numeric(c(x[1,]))
    Inputs3 &lt;-  as.numeric(c(results[1,]))
  
    isolate(grph$try1 &lt;- rbind(Inputs, Inputs2, Inputs3))
  
    grph$try1 &lt;- data.frame(t(grph$try1))
  
  }
  
  })
  
  
  
  output$coolplot &lt;- renderPlotly({p &lt;- plot_ly(data.frame(grph$try1), x = ~Inputs, y = ~Inputs2, type = 'bar', text = round(Inputs2, 2), textposition = 'auto', name = 'Inputs2', marker = list(color = 'rgb(204,204,204)')) %&gt;%
  add_trace(y = ~Inputs3, text = round(Inputs3, 2), textposition = 'auto', name = 'Inputs3', marker = list(color = 'rgb(49,130,189)')) %&gt;%
  layout(title = "Plot", barmode = 'group', yaxis = list(title = "Count"))})
  
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Reproducible Data Samples from the above work:</p>
  
  <p>1- the "raw.csv" with initial 5 rows</p>
  
  <pre><code>structure(list(qout1 = c(6.278, 7.345, 6.609, 6.141, 8.653), 
  qout2 = c(4.399, 5.423, 4.787, 3.947, 5.492), qin1 = c(1.719, 
  3.422, 2.585, 2.308, 2.717), qin2 = c(0.891, 1.663, 1.018, 
  1.484, 1.54), qin3 = c(0.906, 0.742, 0.826, 1.406, 1.621), 
  pin1 = c(1.798, 0.675, 0.743, 1.76, 1.774), pin2 = c(3.377, 
  2.871, 4.857, 3.19, 3.283), pin3 = c(6.42, 8.997, 9.13, 6.136, 
  6.205)), row.names = c(NA, 5L), class = "data.frame")
  </code></pre>
  
  <p>2- the "table1" data from the server side code, first five rows. first row is zero for all variables because new input data was all zero:</p>
  
  <pre><code>structure(c(0, 6.278, 7.345, 6.609, 6.141, 0, 4.399, 5.423, 4.787, 
  3.947, 0, 1.719, 3.422, 2.585, 2.308, 0, 0.891, 1.663, 1.018, 
  1.484, 0, 0.906, 0.742, 0.826, 1.406, 0, 1.798, 0.675, 0.743, 
  1.76, 0, 3.377, 2.871, 4.857, 3.19, 0, 6.42, 8.997, 9.13, 6.136
  ), .Dim = c(5L, 8L), .Dimnames = list(NULL, c("qout1", "qout2", 
  "qin1", "qin2", "qin3", "pin1", "pin2", "pin3"))
  </code></pre>
  
  <p>3- Finally, the "grph$try1" data that is fed to plotly for analysis is as such, first five rows:</p>
  
  <pre><code>structure(list(Inputs = structure(c(3L, 1L, 2L, NA, NA), .Label = 
  c("Fertilizer", "Power", "Seed"), class = "factor"), Inputs2 = 
  structure(c(1L, 1L, 1L, NA, NA), .Label = "0", class = "factor"), 
  Inputs3 = structure(c(1L, 1L, 1L, NA, NA), .Label = "0", class = 
  "factor")), row.names = c("1", "2", "3", "NA", "NA.1"), class = 
  "data.frame")
  </code></pre>