title: How can I trim leading and trailing white space?
body: <p>I am having some trouble with leading and trailing white space in a data.frame.</p>
  <p>For example, I look at a specific <code>row</code> in a <code>data.frame</code> based on a certain condition:</p>
   
  <pre><code>&gt; myDummy[myDummy$country == c(&quot;Austria&quot;),c(1,2,3:7,19)] 
  
  
  
  [1] codeHelper     country        dummyLI    dummyLMI       dummyUMI       
  
  [6] dummyHInonOECD dummyHIOECD    dummyOECD      
  
  &lt;0 rows&gt; (or 0-length row.names)
  </code></pre>
  <p>I was wondering why I didn't get the expected output since the country Austria obviously existed in my <code>data.frame</code>. After looking through my code history and trying to figure out what went wrong I tried:</p>
  <pre><code>&gt; myDummy[myDummy$country == c(&quot;Austria &quot;),c(1,2,3:7,19)]
     codeHelper  country dummyLI dummyLMI dummyUMI dummyHInonOECD dummyHIOECD
  18        AUT Austria        0        0        0              0           1
     dummyOECD
  18         1
  </code></pre>
  <p>All I have changed in the command is an additional white space after Austria.</p>
  <p>Further annoying problems obviously arise. For example, when I like to merge two frames based on the country column. One <code>data.frame</code> uses <code>&quot;Austria &quot;</code> while the other frame has <code>&quot;Austria&quot;</code>. The matching doesn't work.</p>
  <ol>
  <li>Is there a nice way to 'show' the white space on my screen so that I am aware of the problem?</li>
  <li>And can I remove the leading and trailing white space in R?</li>
  </ol>
  <p>So far I used to write a simple <a href="https://en.wikipedia.org/wiki/Perl" rel="noreferrer">Perl</a> script which removes the whites pace, but it would be nice if I can somehow do it inside R.</p>