title: R scaling multiple columns while maintaining one specific column
body: <p>Alright, I've been asked to be more specific and provide code when I ask questions. So here we go!</p>
  
  <p>I need to calculate z-scores for 6 columns in a data set ("Grade2"), which are my 9th-14th columns. Column 1 is a number ID. Columns 2-8 are demographics. Ultimately, I need these scaled columns to be appended onto my existing dataframe. My approach was this: create dataframe of scaled scores, rename columns in new dataframe, merge onto old. </p>
  
  <pre><code>Grade2z = as.data.frame(scale(Grade2[ ,9:14]))#create new dataframe that ONLY has the scaled CBM and aR scores
  colnames(Grade2z) = c("Fallz", "Winterz", "Springz", "aRFallz", "aRWinterz", "aRSpringz")
  Grade2 = merge(Grade2, Grade2z)
  </code></pre>
  
  <p>This caused an issue. Since I had no ID to merge by, it created 40,000 some observations. So I went back and tried this:</p>
  
  <pre><code>    Grade2z = as.data.frame(scale(Grade2[ ,c(1,9:14)]))#create new dataframe that ONLY has the scaled CBM and aR scores
  colnames(Grade2z) = c("Fallz", "Winterz", "Springz", "aRFallz", "aRWinterz", "aRSpringz")
  Grade2 = merge(Grade2, Grade2z)
  </code></pre>
  
  <p>This didn't work either as column 1 is a numeric vector and therefore was also scaled. Is there a simple solution I'm missing? Without manipulating the original dataset (Grade2), how can I create a new one that includes columns 1 and 9:14 without scaling column 1?</p>
  
  <p>Edit: The actual data don't really matter in this case. They are just strings of values. This random dataframe should work. </p>
  
  <pre><code>Grade2 = data.frame(replicate(14, sample(0:50, 1000, rep=FALSE)))
  colnames(Grade2)[1] = "ID"
  </code></pre>