title: Get maximum and minimum values for input$variable Shiny RStudio
body: <p>My name is Nate and I am trying to build a little data analysis tool using Shiny from RStudio. </p>
  
  <p>Right now I am using my own data, but the values are numeric...let's just pretend I am using the mtcars dataset that comes with R.</p>
  
  <p>I would like to:
  1. allow my user to select a numeric variable from a dataframe via a drop down menu </p>
  
  <ol>
  <li><p>have the computer calculate the minimum and maximum values for said variable</p></li>
  <li><p>allow my user to input a number between 1 and 50 from a slider input </p></li>
  <li><p>Divide the difference between the maximum and minimum of the first variable by the value obtained from the slider input</p></li>
  </ol>
  
  <p>The first error I got was:
  1. Non-numeric argument to binary operator</p>
  
  <p>So I tried to coerce the variable using as.numeric(), but this led to my second error:</p>
  
  <ol>
  <li>NAs introduced by coercion </li>
  </ol>
  
  <p>Putting a print(max(input$Var) line in my server.R file gives me the variable name instead of a number. </p>
  
  <p>Any help with this would be greatly appreciated. I have posted part of my ui.r and server.r files below. Thank you in advance.  </p>
  
  <p>ui.R:</p>
  
  <pre><code>library(shiny)
  load('mtcars')
  shinyUI(pageWithSidebar(  
    headerPanel("MtCars Interactive Analysis Tool"),
    sidebarPanel(
  selectInput(inputId = "histVar",
  label= "Pick Your Variable",
  choices=names(mtcars),
  selected = NULL)),
  
  sliderInput(inputId = "binNum",
  label = h5("Number of bins for Histogram--1 through 50 are allowed"),
  min = 1,
  max = 50,
  value = 15, 
  step = 1)
  
  mainpanel(...blah blah blah) 
  </code></pre>
  
  <p>server.R:</p>
  
  <pre><code>library(shiny)
  load("mtcars")
  
  
  shinyServer(function(input, output) {
  
  output$histPlot &lt;- renderPlot({
  
    varRangeGet &lt;- range(input$histVar)
    #print(varRangeGet)
    #print(class(varRangeGet))
    #print(max(input$histVar))
    realRange&lt;-(varRangeGet[[2]]- varRangeGet[[1]])
    binwidthX &lt;- realRange/input$binNum
  
  # Errors out...can't continue
  
  })
  
  
  })
  </code></pre>
  
  <p>Again, thank you for any help on this...I don't understand why I can't perform simple calculations on an input variable within Shiny....</p>