title: R - Assign a value/factor in a data.frame to column conditioned on value(s) of other columns
body: <pre><code>set.seed(8)
  df &lt;- data.frame(n = rnorm(5,1), m = rnorm(5,0), l = factor(LETTERS[1:5]))
  </code></pre>
  
  <p>Have can I make a new column in <code>df</code> conditioned on values or combination of values of n, m and l. 
  For instance make a vector <code>level</code> and assign it <code>low</code>, <code>medium</code> and <code>high</code> based on values of both <code>n</code> and <code>m</code> (pseudo-code):</p>
  
  <pre><code>df$level &lt;- ifelse(df$n &lt; 1 &amp; df$m &lt; 1, "low", ifelse(df$n &gt; 1 &amp; df$m &gt; 1, "high", "medium")
  </code></pre>
  
  <p>This should give:</p>
  
  <pre><code>df$level
  
  #low medium low low medium 
  </code></pre>
  
  <p>Or if I would like to assign a value to <code>level</code> based on the <code>l</code> column and a value in <code>n</code> (again, pseudo-code):</p>
  
  <pre><code>df$level &lt;- ifelse(df$n &lt; 1 &amp; df$l == c("A", "B"), "low A/B", "high").
  </code></pre>
  
  <p>In this case one should get:</p>
  
  <pre><code>df$level
  
  #"low A/B" "high" "high" "high" "high"
  </code></pre>