title: How to add a string only to a subset of a character column in R
body: <p>I have a dataframe similar to this below:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code># A tibble: 32 × 3
    sample     IP  value
     &lt;chr&gt;  &lt;chr&gt; &lt;dbl&gt;
   1 prot1    -IP      0
   2 prot1   Mock      0
   3 prot2    -IP      0
   4 prot2   Mock      0
   5 prot3    -IP      0
   6 prot3   Mock      0
  # … with 22 more rows</code></pre>
  </div>
  </div>
  </p>
  <p>I want to add a string specified by a variable (<code>a &lt;- (&quot;str&quot;)</code> ) only in front of the <code>-IP</code> containing rows in the <code>IP</code> column, obtaining something like:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    # A tibble: 32 × 3
        sample     IP  value
         &lt;chr&gt;  &lt;chr&gt; &lt;dbl&gt;
       1 prot1 str-IP      0
       2 prot1   Mock      0
       3 prot2 str-IP      0
       4 prot2   Mock      0
       5 prot3 str-IP      0
       6 prot3   Mock      0
      # … with 22 more rows</code></pre>
  </div>
  </div>
  </p>
  <p>I guess we can use a combination of <code>paste</code> and <code>filter</code> but I want to keep the entire dataset.</p>