title: For Loop Over List of Data Frames and Create New Data Frames from Every Iteration Using Variable Name
body: <p>I cannot for the life of me figure out where the simple error is in my for loop to perform the same analyses over multiple data frames and output each iteration's new data frame utilizing the variable used along with extra string to identify the new data frame.</p>
  
  <p>Here is my code:</p>
  
  <p><code>john</code> and <code>jane</code> are 2 data frames among many I am hoping to loop over and compare to <code>bcm</code> to find duplicate results in rows.</p>
  
  <pre><code>x &lt;- list(john,jane)
  
  for (i in x) {
    test &lt;- rbind(bcm,i)
    test$dups &lt;- duplicated(test$Full.Name,fromLast=T)
    test$dups2 &lt;- duplicated(test$Full.Name)
    test &lt;- test[which(test$dups==T | test$dups2==T),]
    newname &lt;- paste("dupl",i,sep=".")
    assign(newname, test)
  }
  </code></pre>
  
  <p>Thus far, I can either get the naming to work correctly without including the <code>x</code> data or the loop to complete correctly without naming the new data frames correctly.</p>
  
  <p><strong>Intended Result: I am hoping to create new data frames <code>dupl.john</code> and <code>dupl.jane</code> to show which rows are duplicated in comparison to <code>bcm</code>.</strong></p>
  
  <p>I understand that <code>lapply()</code> might be better to use and am very open to that form of solution. I could not figure out how to use it to solve my problem, so I turned to the more familiar for loop.</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: </p>
  
  <p>Sorry if I'm not being more clear. I have about 13 data frames in total that I want to run the same analysis over to find the duplicate rows in <code>$Full.Name</code>. I could do the first 4 lines of my loop and then <code>dupl.john &lt;- test</code> 13 times (for each data frame), but I am purposely trying to write a for loop or <code>lapply()</code> to gain more knowledge in R and because I'm sure it is more efficient.</p>