title: R- squaring only specific columns
body: <p>Given a data set with a time stamp and several columns of data following it</p>
  
  <pre><code>data=
             hour          V1           V2          V3
  1 2012-01-19 08:00:00  0.04551064  0.002851064  0.01842553
  2 2012-01-19 09:00:00 -0.05305000 -0.052266667 -0.07455000
  3 2012-01-19 10:00:00 -0.07518333 -0.101333333 -0.10670000
  4 2012-01-19 11:00:00 -0.09195000 -0.099383333 -0.11176667
  5 2012-01-19 12:00:00 -0.07743333 -0.074000000 -0.09106667
  6 2012-01-19 13:00:00 -0.10978333 -0.096200000 -0.11343333
  </code></pre>
  
  <p>I would like to square the columns V1-V3 giving me this</p>
  
  <pre><code>data_sq=
           hour                V1           V2           V3
  1    2012-01-19 08:00:00  0.002071218 8.128565e-06 0.0003395002
  2    2012-01-19 09:00:00  0.002814303 2.731804e-03 0.0055577025
  3    2012-01-19 10:00:00  0.005652534 1.026844e-02 0.0113848900
  4    2012-01-19 11:00:00  0.008454803 9.877047e-03 0.0124917878
  5    2012-01-19 12:00:00  0.005995921 5.476000e-03 0.0082931378
  6    2012-01-19 13:00:00  0.012052380 9.254440e-03 0.0128671211
  </code></pre>
  
  <p>As for right now I just use</p>
  
  <pre><code>data_sq&lt;-data^2
  </code></pre>
  
  <p>to get the square root. But it destroys the time stamp so I have to put it back in with something really awkward like</p>
  
  <pre><code>data_sqd&lt;-cbind(data_sq,data$hour)
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>data_sq&lt;-(data[,c(2:4)]^2
  </code></pre>
  
  <p>but I loose the time stamp as well</p>
  
  <p>So how do I keep my time stamp column intact and specify which columns I want to square? My apologies for the lack of reproducible data, but I am hoping this is a simple enough question I can get away with it :)</p>