min for each row in a data frame
<p>I'm try to calculate minimum across multiple columns (row-wise <code>min</code>) in a data frame, but the <code>min</code> function automatically returns the minimum across the whole of each column rather than for each row separately. I'm sure I'm missing something really simple here? Any ideas much appreciated.</p>
<pre><code>x &lt;- c(1,2,7)
y &lt;- c(1,5,4)
minIwant &lt;- c(1,2,4)
df &lt;- data.frame(x, y, minIwant)
df$minIget &lt;- min(df$x,df$y)
df
  x y minIwant minIget
1 1 1        1       1
2 2 5        2       1
3 7 4        4       1
</code></pre>