title: Calling user inputs prompted through one R function in a second R function
body: <p>Thank you very much in advance for helping me out - I am new to R programming, and have got stuck with trying to use user-inputs accepted through one function within another. The second function is a simple pay calculator where the three variables are number of hours, per hour pay rate and the number of times the rate is multiplied once the number of working hours exceeds 180. I have written a first function called enterval through which I am asking the user to enter the above variables. In a second function called salary, I am trying to use enterval to accept the inputs before running the payout calculations. I am getting stuck because the second function, salary, is breaking when I come to an "if" condition, specifying if h > 180. I am sharing my code below. Thanks again for your kind assistance. I searched among previous answers but could not find a specific instance that fully answered my query - apologies if I missed out an appropriate previous response.
  The error I am getting on running this code is "Error in h > 180 : 
    comparison (6) is possible only for atomic and list types"</p>
  
  <pre><code>enterval &lt;- function()  {
  h &lt;- (readline("Please enter number of hours: "))
  h &lt;- as.integer(h)
  r &lt;- (readline("Please enter applicable rate: "))
  r &lt;- as.integer(r)
  m &lt;- (readline("Please confirm your multiplier: "))
  m &lt;- as.integer(m)
  }
  salary &lt;- function ()  {
      enterval()
      if (h &gt; 180)  {
          totalpay &lt;- (180*r) + ((h-180)*r*m)
          }
      else  {
          totalpay &lt;- (h*r)
          }
      totalpay
  }
  </code></pre>