title: Equivalent of ternary operator in R
body: <p>In C++ the ternary operator enables shorthand conditional assignment of variable values:</p>
  <pre><code>x = y &gt; 2 ? y : 2; 
  </code></pre>
  <p>In R, the closest operation of which I am aware is the following:</p>
  <pre><code>ifelse(y &gt; 2, x &lt;- y, x &lt;- 2)
  </code></pre>
  <p>It just feels clumsy and looks OO awkward to type <code>x</code> twice on the same line, especially when doing this dozens of times. Is there a cleaner method for conditional assignment in R?</p>