title: Recoding values of multiple variable with same suffix to new variable with different suffix in R
body: <pre><code>library(Hmisc)
  install.packages(&quot;expss&quot;)
  col1.5pt &lt;- c(1,2,4,5)
  col2.5pt &lt;- c(1,2,3,4)
  col3 &lt;- c(3,4,5,1)
  col4.5pt &lt;- c(2,3,2,4)
  col5 &lt;- c(3,NA,4,5)
  df&lt;- data.frame(col1.5pt,col2.5pt,col3,col4.5pt,col5)
  abc &lt;- c(&quot;col1.5pt&quot;, &quot;col2.5pt&quot;, &quot;col4.5pt&quot;)
  cde &lt;- c(&quot;col1.T2b&quot;, &quot;col2.T2b&quot;, &quot;col4.T2b&quot;)
  df[cde]&lt;-sapply(df[abc], function(x) recode(x,1:2~1,3~2,4:5~3))
  </code></pre>
  <p>I have to basically recode variables of .5pt into .T2b. At the moment, I am picking these variables but since I have lots of datasets where I have to create these kinds of variables. I want something where I can pick all the variables with .5pt and recode them into .T2b. I am new to R and trying to learn to automate my code. Thanks for help in advance.</p>