title: Coding a new variable according to the range of existing variables
body: <p>I wrote the code below using "ifelse" function, 
  which only returns "worker" to a$age_group , the new column I want to create according to the variable "age" but only.</p>
  
  <p>I don't know why... can you help me debug my code?</p>
  
  <pre><code>for(i in 1:length(a$age))
  {
      ifelse(a$age&lt;17, a$age_group&lt;-"mid", 
                       ifelse(a$age&lt;20, a$age_group&lt;-"high", 
                                        ifelse(a$age&lt;24, a$age_group&lt;-"univ", 
                                                         a$age_group&lt;-"worker")))
  }
  </code></pre>