title: Eliminating partially overlapping parts of 2 vectors in R
body: <p>I wonder if it might be possible to drop the parts in <code>n1</code> character vector that <em><strong>partially overlap</strong></em> with elements in <code>f1</code> formula.</p>
  <p>For example, in <code>n1</code>, we see <code>&quot;study_typecompare&quot;</code> &amp; <code>&quot;study_typecontrol&quot;</code> partially overlap with <code>study_type</code> in <code>f1</code>.</p>
  <p>Thus in the <code>desired_output</code>, we want to drop the <code>&quot;study_type&quot;</code> part of them. Because other elements (ex. <code>time_wk_whn</code>) in <code>n1</code> fully overlap with an element in <code>f1</code>, we leave them unchanged.</p>
  <p>Is obtaining my <code>desired_output</code> possible in BASE <code>R</code> or tidyvesrse?</p>
  <pre><code>f1 &lt;- gi ~ 0 + study_type + time_wk_whn + time_wk_btw + items_whn + 
    items_btw + training_hr_whn + training_hr_btw
  
  n1 &lt;- c(&quot;study_typecompare&quot;,&quot;study_typecontrol&quot;,&quot;time_wk_whn&quot;,      
          &quot;time_wk_btw&quot;,&quot;items_whn&quot;,&quot;items_btw&quot;,&quot;training_hr_whn&quot;,
          &quot;training_hr_btw&quot;) 
  
  desired_output &lt;- c(&quot;compare&quot;,&quot;control&quot;, &quot;time_wk_whn&quot;,      
                      &quot;time_wk_btw&quot;,&quot;items_whn&quot;,&quot;items_btw&quot;,        
                      &quot;training_hr_whn&quot;,&quot;training_hr_btw&quot;)
  
  </code></pre>