title: Searching for specified pattern in R list
body: <p>I have a dataset stored as a list DataList</p>
  
  <pre><code>[[1]]
  
  [1] a  
  
   [2] f 
  
   [3] e       
  
   [4] a 
  
  [[2]] 
  
   [1] f 
  
   [2] f
  
   [3] e
  </code></pre>
  
  <p>I am trying to create a function Getfrequence which return the frequence of a given pattern in the list DataList</p>
  
  <pre><code>GetFrequence&lt;- function(pattern, DataList)
  {
  freq= 0
  i = 1
  while (i&lt;= List.length())
   {
    if (.....)
      freq= freq + 1
   }
   return freq
  }
  </code></pre>
  
  <p>My question is how can I search if the given pattern exists in the list?</p>