title: Create a categorical variable (age categories) and apply to a table
body: <p>I'm working with a large table with many variables, including "age".
  Here is an example of what my table looks like:</p>
  
  <ol>
  <li>Age  Var2   Var3   Var4    Var5 </li>
  <li>32   John  Green  Married   6'1</li>
  <li>47   Julia Stone  Divorced  5'4</li>
  <li>72   Mike  White  Divorced  5'8</li>
  </ol>
  
  <p>...</p>
  
  <p>I am trying to add a variable to this table that classifies age in categories of 10 years, starting from 20 years old.</p>
  
  <p>I have created my criterias:</p>
  
  <pre><code>mydata$age[mydata$age&gt;=20 &amp; mydata$age&lt;=29] &lt;- "20-29"
  mydata$age[mydata$age&gt;=30 &amp; mydata$age&lt;=39] &lt;- "30-39"
  mydata$age[mydata$age&gt;=40 &amp; mydata$age&lt;=49] &lt;- "40-49"
  mydata$age[mydata$age&gt;=50 &amp; mydata$age&lt;=59] &lt;- "50-59"
  mydata$age[mydata$age&gt;=60 &amp; mydata$age&lt;=69] &lt;- "60-69"
  mydata$age[mydata$age&gt;=70 &amp; mydata$age&lt;=79] &lt;- "70-79"
  </code></pre>
  
  <p>Now, i want to add this as a variable in my table. So I want this variable to apply the right age category to every age listed in my data table. Here is an example of what it should look like:</p>
  
  <ol>
  <li>Age  Var2   Var3   Var4    Var5  AgeClass</li>
  <li>32   John  Green  Married  6'1   30-39</li>
  <li>47   Julia Stone  Divorced 5'4   40-49</li>
  <li>72   Mike  White  Divorced 5'8   70-79
  ...</li>
  </ol>
  
  <p>Anyone has an idea how to do that?
  Thank you!</p>