title: If else condition not responding in shiny , r
body: <p>I will like to ask for help here as I am using Shiny in R for the first time. I am trying to display the values height and weight from the calculations and conversions done depending on the type of measurement system (imperial or metric) chosen. This is by using the if .. else statement in my script but it seems that the condition isn't working.In essence I want the bmi in &quot;output$bmi&quot; to be displayed based on the measurement system chosen.My code is as follows:</p>
  <p><strong>ui.r</strong></p>
  <pre><code>library(shiny)
  
  shinyUI(fluidPage(
      
    # Application title
    headerPanel(&quot;Healthy Weight Checker&quot;),
      
    # Sidebar with 
    sidebarLayout(
      sidebarPanel(
         h4(&quot;Check your Body Mass Index (BMI) to see if you have a healthy weight.&quot;),
        textInput(&quot;text1&quot;, label = h4(&quot; Your Name&quot;)),
        radioButtons(&quot;gender&quot; , label = h4(&quot;Your gender&quot;), list(&quot;Male&quot;,&quot;Female&quot;)), 
        numericInput('age', label = h4(&quot;Your Age&quot;),0, min=0, max=120, step=1),
                      
                     
        # selectInput(&quot;stm&quot;, label= h4(&quot;System of Measurement&quot;), c(&quot;Imperial (Pounds, Feet)&quot; = &quot;imperial&quot;, &quot;Metric (Kilogrammes, Meters)&quot; = &quot;metric&quot;)),
                 
        selectInput(&quot;sm&quot;, label=h3(&quot;Select Sytem of Measurement&quot;), choices=c(&quot;Metric&quot;, &quot;Imperial&quot;)), 
        fluidRow(          
          column(6, numericInput('height', 'Height',0, min = 0, max = 7, step= 0.01)),
          column(6,numericInput('weight', 'Weight',0, min = 0, max = 300, step= 0.01))
        ),
              
        submitButton(&quot;Calculate&quot;),
        br(),
        br()
      ),    
                 
      mainPanel(
        p(h4(&quot;Your personal information&quot;)),
        textOutput(&quot;text1&quot;),
        textOutput(&quot;gender&quot;),
        textOutput(&quot;age&quot;),
        textOutput(&quot;sm&quot;),
        textOutput(&quot;height&quot;),
        textOutput(&quot;weight&quot;),
        textOutput(&quot;bmi&quot;)
      )
    )            
  ))
  </code></pre>
  <p><strong>server.r</strong></p>
  <pre><code>shinyServer(function(input, output) {
     
    output$text1 &lt;- renderText({ 
      paste(&quot;Name: &quot;, input$text1)
    })
    output$gender &lt;- renderText({ 
      paste(&quot;Gender: &quot;, input$gender)
    })
    output$age &lt;- renderText({ 
      paste(&quot;Age: &quot;, input$age)
    })
    output$sm &lt;- renderText({ 
      paste(&quot;Measurement system: &quot;, input$sm)
    })
    output$height &lt;- renderText({ 
      paste(&quot;Your height: &quot;, input$height)
    })
    output$weight &lt;- renderText({ 
      paste(&quot;Your weight: &quot;, input$weight)
    })
     
      
    values &lt;- reactiveValues()         
    observe({
      if(input$sm == 'metric'){
        values$obj &lt;- as.numeric(input$weight/(input$height)^2)   
      } else {
        values$obj &lt;- values$obj * 730
      }
    })
    
    output$bmi &lt;- renderText({ # Print the result to the main panel
      obj &lt;- values$obj
      print(obj)
    })
  })
  </code></pre>