title: How to add a column after the last column containing a certain string?
body: <p>I have a dataset like this</p>
  
  <pre><code>df &lt;- data.frame(abc_1 = 1:10, abc_2 = 11:20, abc_3 = 21:30, somevar = 31:40)
  head(df)
     abc_1 abc_2 abc_3 somevar
  1      1    11    21      31
  2      2    12    22      32
  3      3    13    23      33
  4      4    14    24      34
  5      5    15    25      35
  6      6    16    26      36
  </code></pre>
  
  <p>I would like to insert a new column after abc_3 (in my case the row sums of abc_1, abc_2, abc_3). Since (a) the dataset is huge, (b) I might decide to manipulate the dataset before adding the column (i.e. messing up the column indices), and since (c) I would like to do this for many variables that contain some different string, I am looking to use a way of doing this without referencing the column index but rather by matching the string abc.</p>
  
  <p>I have found add_column in the tibble package but it only allows adding the column by its index like so</p>
  
  <pre><code>library(tibble)
  add_column(df, abc_sum = rowSum(abc_1, abc_2, abc_3), .after = 3)
  </code></pre>
  
  <p>What I want is something like this:</p>
  
  <pre><code>   abc_1 abc_2 abc_3 abc_sum somevar
  1      1    11    21      33      31
  2      2    12    22      36      32
  3      3    13    23      39      33
  4      4    14    24      42      34
  5      5    15    25      45      35
  6      6    16    26      48      36
  </code></pre>
  
  <p>I am looking to replace the <code>.after = 3</code> with an expression that inserts it after abc_3 by matching the string abc_3.</p>