title: removing trailing spaces with gsub in R
body: <p>Does anyone have a trick to remove trailing spaces on variables with gsub?</p>
  
  <p>Below is a sample of my data.  As you can see, I have both trailing spaces and spaces embedded in the variable.  </p>
  
  <pre><code>county &lt;- c("mississippi ","mississippi canyon","missoula ",
              "mitchell ","mobile ", "mobile bay")  
  </code></pre>
  
  <p>I can use the following logic to remove all spaces, but what I really want is to only move the spaces at the end.</p>
  
  <pre><code>county2 &lt;- gsub(" ","",county)
  </code></pre>
  
  <p>Any assistance would be greatly appreciated.</p>