title: Replace given value in vector
body: <p>I'm looking for a function which will replace all occurrences of one value with another value.
  For example I'd like to replace all zeros with ones.
  I don't want to have to store the result in a variable, but want to be able to use the vector anonymously as part of a larger expression.</p>
  
  <p>I know how to write a suitable function myself:</p>
  
  <pre><code>&gt; vrepl &lt;- function(haystack, needle, replacement) {
  +   haystack[haystack == needle] &lt;- replacement
  +   return(haystack)
  + }
  &gt; 
  &gt; vrepl(c(3, 2, 1, 0, 4, 0), 0, 1)
  [1] 3 2 1 1 4 1
  </code></pre>
  
  <p>But I'm wondering whether there is some standard function to do this job, preferrably from the <code>base</code> package, as an alternative from some other commonly used package. I believe that using such a standard will likely make my code more readable, and I won't have to redefine that function wherever I need it.</p>