title: R loop and filter
body: <p>So I don't how to go about asking this, I'm having a hard time googling as well so I figured asking with actual code would be better.</p>
  
  <p>I'm new to R, I'm trying to teach myself and so far I'm picking up the basics, however I came across a situation now where I figured looping through would be a better option but I have no idea where to begin.</p>
  
  <p>Right now I'm just making random csv files with all the states in them but multiple of the same entry just for fun. </p>
  
  <p>I've learned with the library 'dplyr' I can filter by topic</p>
  
  <p>hence:</p>
  
  <pre><code>temp &lt;- filter(states, State="AL")
  </code></pre>
  
  <p>which I know assigns all rows that have State='AL' to temp</p>
  
  <p>so instead of going state by state temp by temp, I'm trying to learn how I can develop a loop that can check the topic of the state and assign to temps dynamically so theoritically</p>
  
  <pre><code>temp1 &lt;- filter(states, State="AL")
  temp2 &lt;- filter(states, State="CA")
  ....and so on
  </code></pre>
  
  <p>I'm just trying to figure out how I can loop through a files topic and assign it dynamically and then write each one dynamically to their own files. </p>
  
  <pre><code>write.csv(temp1, "AL.csv")
  </code></pre>
  
  <p>Even leading me to some where that can help me figure it out would be beneficial. I'm just stuck now and I know it's possible, or at least I think I do.</p>