title: Clip values between a minimum and maximum allowed value in R
body: <p>In Mathematica there is the command <code>Clip[x, {min, max}]</code>
  which gives <code>x</code> for <code>min&lt;=x&lt;=max</code>, <code>min</code> for <code>x&lt;min</code> and and <code>max</code> for <code>x&gt;max</code>, see</p>
  <p><a href="http://reference.wolfram.com/mathematica/ref/Clip.html" rel="nofollow noreferrer">http://reference.wolfram.com/mathematica/ref/Clip.html</a>  (<a href="https://web.archive.org/web/20170816183037/http://reference.wolfram.com/language/ref/Clip.html" rel="nofollow noreferrer">mirror</a>)</p>
  <p>What would be the fastest way to achieve this in R? Ideally it should be a function that is listable, and should ideally work on either a single value, vector, matrix or dataframe...</p>