title: how to use a variable in grepl function within a loop-R
body: <p>I am new to R and, have some problems with looping and grepl functions
  I have a data from like: </p>
  
  <pre><code>str(peptidesFilter)
    'data.frame':   78389 obs. of  130 variables:
   $ Sequence                      : chr  "AAAAAIGGR" "AAAAAIGGRPNYYGNEGGR" "AAAAASSNPGGGPEMVR" "AAAAAVGGR" ...
   $ First.amino.acid              : chr  "A" "A" "A" "A" ...
   $ Protein.group.IDs             : chr  "1" "1;2;4" "2;5 "3" "4;80" ...
  </code></pre>
  
  <p>I want to filter the data according to $ Protein.group.IDs by using grepl function below </p>
  
  <pre><code>    peptidesFilter.new &lt;- peptidesFilter[grepl('(^|;)2($|;)',
  peptidesFilter$Protein.group.IDs),]
  </code></pre>
  
  <p>I want to do it with a loop for every individual data ( e.g 1, 2, 3, etc...)
  and re-write name of data frame containing variable peptidesFilter.i</p>
  
  <pre><code>   i =1
     while( i &lt;= N) { peptidesFilter.[[i]] &lt;- 
     peptidesFilter[grepl('(^|;)i($|;)',
     peptidesFilter$Protein.group.IDs),] 
      i=i+1 }
  </code></pre>
  
  <p>i have two problems, 
  main one i in the grep1 function does not recognized as a variable and how i can re-name filtered data in a way it will contain variable.</p>
  
  <p>any ideas?</p>