title: replace a whole sentence with a string in r
body: <p>I need to replace a whole sentence with a string. For example:</p>
  <pre><code># I want to replace &quot;coarse particulate matter (Hourly measured)&quot; with &quot;pm10&quot;
  species &lt;- c(&quot;coarse particulate matter (Hourly measured)&quot;,&quot;nitrogen dixoide&quot;)
  
  # I tried:
  sub(&quot;coarse particulate matter (Hourly measured)&quot;,&quot;pm10&quot;,species)
  gsub(&quot;coarse particulate matter (Hourly measured)&quot;,&quot;pm10&quot;,species)
  str_replace(species,&quot;coarse particulate matter (Hourly measured)&quot;,&quot;pm10&quot;)
  </code></pre>
  <p>But none of them works. Many thanks for help.</p>
  <p>In the real data, the orders are random. That is why I can not use things like</p>
  <pre><code>species[1] &lt;- &quot;pm10&quot;
  </code></pre>