title: squaring a large subset of columns in R
body: <p>How can I create squared columns? I know how to do this for individual columns, but I need a loop/function that takes the square of multiple columns at once (all of them starter with &quot;player&quot;). In reality, my dataframe contains a lot of players, so i need an efficient command.
  Mutate_at is useful, but i also need to create new column names.</p>
  <pre><code>df &lt;- data.frame(season = c(1,2,3), player1 = c(1,2,3),  player2= c(3,4,5))
  
  #desired result: 
  
  # season player1 player2 squared1 squared2
  # 1        1        3       1        9
  # 2        2        4       4        16
  # 3        3        5       9        25
  </code></pre>