title: If (no else)-sentences with substring in R
body: <p>I have a df, I would like to substring the first letters for all columns in the screen_name column, except for the cell with the name 'frank'. All my attempts are ignored by R (substring is executed on all cells). Why?</p>
  <pre><code>
  df &lt;- data.frame(&quot;screen_name&quot; = c(&quot;august&quot;, &quot;berit&quot;, &quot;christopher&quot;, &quot;david&quot;, &quot;erica&quot;, &quot;frank&quot;), &quot;rt_name&quot; = c(&quot;berit&quot;, &quot;august&quot;, &quot;david&quot;, &quot;erica&quot;, &quot;frank&quot;, &quot;christopher&quot;))
  
  #IF-sentence with '%!like%' 
  '%!like%' &lt;- function(x,y)!('%like%'(x,y))
  df$screen_name&lt;- if(df$screen_name %!like% ('frank')) {substr(df$screen_name, 1, 2)}
  
  #IF-sentence with !=
  df$screen_name&lt;- if(df$screen_name != 'frank') {substr(df$screen_name, 1, 2)}
  </code></pre>
  <p>I am looking for solution that include %!like% or similar as the names in the df can vary and I am not always having an exact match.</p>
  <p>My expected output is</p>
  <pre><code>df_exp &lt;- data.frame(&quot;screen_name&quot; = c(&quot;au&quot;, &quot;be&quot;, &quot;ch&quot;, &quot;da&quot;, &quot;er&quot;, &quot;frank&quot;), &quot;rt_name&quot; = c(&quot;berit&quot;, &quot;august&quot;, &quot;david&quot;, &quot;erica&quot;, &quot;frank&quot;, &quot;christopher&quot;))
  
  </code></pre>
  <p>Thanks in advance!</p>