title: R: Rename or copy dataframe and naming it as defined in a vector
body: <p>I want to create a new dataframe from an existing one and naming it as defined in a vector:</p>
  
  <p>I have a dataset with many different questions, and to go through the dataset a bit quicker, I have developed a list of generic functions that can be called upon. For each question, I define the specific values, such as can be seen below. In the second part, I more or less create a clean dataset for the question, which is saved as a dataframe called 'questionid'. Because that variable is overwritten with each question, <strong>I want to create a duplicate of this dataframe and call it as specified under 'questionname'</strong> (in this case "A1"). I find it very difficult to find easy ways to do that. I hope someone can help me.</p>
  
  <pre><code># Specify vectors and variables
    question &lt;- "Would you recommend edX to a friend of you?" 
    questionname &lt;- "A1" 
    edXid &lt;- "i4x-DelftX-ET3034TUx-problem-b3d30df864ca41ffa0170e790f01a783_2_1" 
    clevels &lt;- c("0 - Not at all likely", "1", "2", "3", "4", "5 - Neutral", "6", "7", "8", "9", "10 - Extremely likely") 
    csvname &lt;- paste(questionname, ".csv", sep="") 
    pngname &lt;- paste(questionname, ".png", sep="") 
  
  # Run code
    questionid &lt;- subset(allDatasolar, allDatasolar[,3]==edXid, select = -c(X,question))
    questionid &lt;- questionid[-grep("dummy", questionid$answer), ] 
    questionid &lt;- droplevels(questionid) 
    # as.name(questionname) &lt;- as.data.frame(questionid) # does not work
    questionid$answer &lt;- factor(questionid$answer, ordered=TRUE, levels=clevels) 
    write.csv(data.frame(summary(questionid$answer)), file = csvname) 
    png(file = pngname, width = 640) 
    barchart(questionid$answer, main = question, xlab = "", col='lightblue')
    dev.off() 
  </code></pre>