title: Loop over character variables in R
body: <p>*I've read the related questions here, but I'm struggling to adapt the answers to my code.</p>
  <p>I am trying to run the following command:</p>
  <pre><code>clist = c(&quot;QB&quot;, &quot;WR&quot;, &quot;TE&quot;, &quot;RB&quot;)
  for (i in unique(data$clist)) {
     data_i = subset(data, data$position == i)
  }
  
  </code></pre>
  <p>to create subsets of my data for the different football positions (i.e. data_QB, data_WR, data_TE, data_RB).</p>
  <p>However, this is not working. I understand that this is because R doesn't recognize that I'm trying to use &quot;i&quot; as a string variable, but don't know how to fix my code. Any thoughts would be much appreciated!</p>