title: for loop on character variables
body: <p>I have a data set having 3 columns <code>Part</code>, <code>Claimid</code> and <code>Cost</code>. The dataset looks as below:</p>
  <pre><code>Part  Claimid Cost
  Part1 ID1 12
  Part1 ID20 29
  Part2 ID21 21
  Part2 ID40 13
  Part3 ID41 11
  Part3 ID60 10
  </code></pre>
  <p>The cost column is a random number between 1 to 10
  I am trying to run a loop for every <code>Part</code> (here 3 parts) and use dplyr package to create three distinct data frames</p>
  <pre><code>library(dplyr)
  claimid &lt;- read.csv(file.choose(),header = TRUE)
  plist &lt;- unique(claimid$Part) ##Create the number of loops (Here 3)
  for (i in plist) {
      plist &lt;- claimid %&gt;% select(Part,Claimid) %&gt;% filter(Part %in% i)
  }
  </code></pre>
  <p>I am getting the last 20 observations when I print plist because obviously R is saving the last observation of loop.</p>