title: How to complete several character vector formatting steps in a single function?
body: <p><strong>EDITED</strong></p>
  
  <p>I have a simple list of column names that I would like to change the format of, ideally programmatically. This is a sample of the list: </p>
  
  <pre><code>    vars_list &lt;- c("tBodyAcc.mean...X", "tBodyAcc.mean...Y", "tBodyAcc.mean...Z",
      "tBodyAcc.std...X", "tBodyAcc.std...Y", "tBodyAcc.std...Z", 
      "tGravityAcc.mean...X", "tGravityAcc.mean...Y", "tGravityAcc.mean...Z",
      "tGravityAcc.std...X", "tGravityAcc.std...Y", "tGravityAcc.std...Z",
      "fBodyAcc.mean...X", "fBodyAcc.mean...Y", "fBodyAcc.mean...Z", 
      "fBodyAcc.std...X", "fBodyAcc.std...Y", "fBodyAcc.std...Z",
      "fBodyAccJerk.mean...X", "fBodyAccJerk.mean...Y", "fBodyAccJerk.mean...Z",
      "fBodyAccJerk.std...X", "fBodyAccJerk.std...Y", "fBodyAccJerk.std...Z")
  </code></pre>
  
  <p>And this is the result I'm hoping for:</p>
  
  <pre><code> [3]"Time_Body_Acc_Mean_X"                "Time_Body_Acc_Mean_Y"               
   [5] "Time_Body_Acc_Mean_Z"                "Time_Body_Acc_Stddev_X"             
   [7] "Time_Body_Acc_Stddev_Y"              "Time_Body_Acc_Stddev_Z"             
   [9] "Time_Gravity_Acc_Mean_X"             "Time_Gravity_Acc_Mean_Y"            
  [11] "Time_Gravity_Acc_Mean_Z"             "Time_Gravity_Acc_Stddev_X"          
  [13] "Time_Gravity_Acc_Stddev_Y"           "Time_Gravity_Acc_Stddev_Z"
  </code></pre>
  
  <p>...</p>
  
  <pre><code>[43] "Freq_Body_Acc_Mean_X"                "Freq_Body_Acc_Mean_Y"               
  [45] "Freq_Body_Acc_Mean_Z"                "Freq_Body_Acc_Stddev_X"             
  [47] "Freq_Body_Acc_Stddev_Y"              "Freq_Body_Acc_Stddev_Z"             
  [49] "Freq_Body_Acc_Jerk_Mean_X"           "Freq_Body_Acc_Jerk_Mean_Y"          
  [51] "Freq_Body_Acc_Jerk_Mean_Z"           "Freq_Body_Acc_Jerk_Stddev_X"        
  [53] "Freq_Body_Acc_Jerk_Stddev_Y"         "Freq_Body_Acc_Jerk_Stddev_Z" 
  </code></pre>
  
  <p>I've put together what feels like a really verbose way of making the changes employing regular expressions.</p>
  
  <pre><code>vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("^t", "Time", x)}))
  vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("^f", "Freq", x)}))
  vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("std", "Stddev", x)}))
  vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("mean", "Mean", x)}))
  vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("\\.+", "", x)}))
  vars_list &lt;- unlist(lapply(vars_list, function(x){gsub("\\.", "", x)}))
  vars_list &lt;- unlist(lapply(vars_list, 
                             function(x){gsub("(?&lt;=[a-z]).{0}(?=[A-Z])",
                                              "_", x, perl = TRUE)}))
  </code></pre>
  
  <p>Is there a way to arrive at the same results more efficiently and elegantly by including two or more formatting steps in a single function call?</p>