title: gsub() everything except specified characters?
body: <p>How do I gsub() everything except a specified character in R?</p>
  
  <p>In my problem I have the following string...</p>
  
  <pre><code>"the quick brown fox jumps over a lazy dog"
  </code></pre>
  
  <p>I have to generate a new string with by removing all characters except 'r' and 'o' and get the following output...</p>
  
  <pre><code>"roooro"
  </code></pre>
  
  <p>Assuming all characters are lower case how do I go about. I tried...</p>
  
  <pre><code>gsub(!"r","",gsub(!"o","",str1))
  </code></pre>
  
  <p>But the '!' doesn't work.</p>