title: R - Replace multiple values in data.frame with one value
body: <p>I am using R and want to replace multiple values in data.frame starting with certain letters with one value.</p>
  
  <p>For example below is the sample values in my data frame like XYZ1, XYZ2, XYZ3, XYZ4.. etc then i want to replace all values which starts with "XYZ" to "ABC"</p>
  
  <p>Example</p>
  
  <p>df is the data frame</p>
  
  <pre><code> V1    V2   V3   V4 
  
  XYZ1  XYZ2 XYZ4 XYZ10
  
  XYZ3  RST1 WST3 XYZ11
  </code></pre>
  
  <p>Here (V1-V4) are the columns on which i want to replace all values which starts with "XYZ"  change to "ABC".</p>
  
  <p>Result i want is</p>
  
  <p>df &lt;-</p>
  
  <pre><code>V1   V2   V3   V4 
  
  ABC  ABC  ABC  ABC
  
  ABC  RST1  WST3  ABC
  </code></pre>
  
  <p>Individually i can do this by using == operator on each value in each column after converting them to character values, but how can i convert all values across multiple columns at once?</p>