title: Adding prefixes to some variables without touching others?
body: <p>I'd like to produce a data frame like df3 from df1, ie adding a prefix (important_) to variables without one, whilst not touching variables with certain prefixes (gea_, win_, hea_). Thus far I've only managed something like df2 where the important_ variables end up in a separate dataframe, but I'd like all variables in the same data frame. Any thoughts on it would be much appreciated.    </p>
  
  <p>What I've got:</p>
  
  <pre><code>library(dplyr)
  
  df1 &lt;- data.frame("hea_income"=c(45000,23465,89522),"gea_property"=c(1,1,2) ,"win_state"=c("AB","CA","GA"), "education"=c(1,2,3), "commute"=c(13,32,1))
  
  df2 &lt;- df1 %&gt;% select(-contains("gea_")) %&gt;% select(-contains("win_")) %&gt;% select(-contains("hea_"))  %&gt;% setNames(paste0('important_', names(.)))
  </code></pre>
  
  <p>What I would like:</p>
  
  <pre><code>df3 &lt;- data.frame("hea_income"=c(45000,23465,89522),"gea_property"=c(1,1,2) ,"win_state"=c("AB","CA","GA"), "important_education"=c(1,2,3), "important_commute"=c(13,32,1))
  </code></pre>