title: How to change multiple variable names in R?
body: <p>I am new to R</p>
  
  <p>I am trying to create a variable list with variables containing the log of some other variables. I managed to create the list, but I don't know how to rename each variable. Moreover, I don't know how to make these variables be a part of my dataset. Here is what I do: </p>
  
  <p>Imagine somedata is a csv file of the form: </p>
  
  <pre><code>v1,  v2,  v3, ...,  vn
  1, 4, 6,    ...,  1
  ...
  </code></pre>
  
  <p>Then here is my script</p>
  
  <pre><code>##################
  ## Import Data
  ###################
  lights &lt;- read.csv("somedata.csv")  
  
  ##################
  ## Variable Lists
  ###################
   lights.varlist1 &lt;- subset(lights, select=c(v1,v2,...,vJ))
  
   ###########
   ## Logs
   ###########
  
   lights.logsvarlist1=apply(lights.varlist1, 2, function(y) log(y))
  </code></pre>
  
  <p>This part seems to be working just fine as the results of <code>print(lights.logsvarlist1)[1,]</code> make sense</p>
  
  <p>To change the names of the variables I do: </p>
  
  <pre><code>for (i in 1:length(lights.logsvarlist1[1,]) {
      name &lt;-paste("l", names(lights.varlist1)[i], separator="")
      names(lights.logsvarlist1)[i]=name
  }
  </code></pre>
  
  <p>I have now two problems. </p>
  
  <ol>
  <li><p>When I <code>print(lights.logsvarlist1[1,]</code>, the names don't seem to have changed. I still have my old variable names as headers. </p></li>
  <li><p>When I <code>print(names(lights))</code>, my newly created variables don't seem to be part of the dataset (they are not in the list). </p></li>
  </ol>
  
  <p>What am I doing wrong? I am very new to R and I really want to continue, I'd appreciate any help. </p>