title: Delete column and next column based on text
body: <p>I have a data like this :</p>
  <p><a href="https://i.stack.imgur.com/zvBE9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zvBE9.png" alt="enter image description here" /></a></p>
  <p>and I want to delete the column which contain &quot;rico&quot; and also delete all next columns. I am looking to get this :
  <a href="https://i.stack.imgur.com/0w0Jl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0w0Jl.png" alt="enter image description here" /></a></p>
  <p>This is what i did but it doesnt work :</p>
  <pre><code>mydata = data.frame(
    X1 = c(&quot;john&quot;, &quot;max&quot;, &quot;jay&quot;, &quot;douglas&quot;),
    X2 = c(&quot;alexia&quot;, &quot;miguel&quot;, &quot;vince&quot;, &quot;gary&quot;),
    X3 = c(&quot;peter&quot;, &quot;rico&quot;, &quot;joe&quot;, &quot;jenny&quot;),
    X4 = c(&quot;marc&quot;, &quot;kelly&quot;, &quot;max&quot;, &quot;jones&quot;)
  )
  
  mydata[,grepl(&quot;rico&quot;, names(mydata))]
  </code></pre>
  <p>Some help would be appreciated</p>