title: Saving ngram objects in a dataframe
body: <pre><code>require(ngram)
  require(stringr)
  res&lt;-readLines("text1.txt")
  wordlength=0
  
  for(j in 1:length(res) ){
  temp&lt;-sapply(strsplit(res[j]," "), length)
   if (temp&gt;=wordlength) {
      wordlength=temp
   }
  }
  
  rm("temp")
  data&lt;-data.frame
  
  for(i in 1:length(res) ){
  x&lt;-res[i]
  ng&lt;-ngram(x,n=2)
  temp&lt;-babble(ng,genlen=500,seed=123)
  data[i]&lt;-ngram(temp,n=2)
  }
  
  get.ngrams(ngram(bab[1,],n=2))
  babng&lt;-matrix(nrow=length(res),wordlength)
  </code></pre>
  
  <p>I'm trying to save my ngram data in a data frame from this loop, I've also tried to save it in a matrix but this error is showing:</p>
  
  <pre><code>"object of type 'closure' is not subsettable"
  </code></pre>
  
  <p>I want to get the frequency distribution of the every 2gram element from the babbler. Sorry for my messy coding. I'm new to R.</p>