title: R loop for creating and using -csv
body: <p>I have a function output (from koRpus) of the form:
  Total number of tokens: 887
  Total number of types:  393</p>
  
  <p>Measure of Textual Lexical Diversity
                  MTLD: 142.66
     Number of factors: 6.22
           Factor size: 0.72
      SD tokens/factor: 41.55 (all factors)
                        38 (complete factors only)</p>
  
  <p>And I want to make a loop for storing these results for 80 different documents. I have tried the following:</p>
  
  <pre><code>for (i in 1:length(infra$tableid)) {
    whypar &lt;- paste(infra$whypar [infra[,1] ==i], collapse=" ")
  wpi&lt;- removeWords(whypar, stopwords("english"))
  
  as.data.frame(wpi)
  write.csv(data.frame(wpi), file= "wp.csv")
  
  tagged.text &lt;- tokenize("wp.csv", lang="en")
  
  res.mtld &lt;- MTLD(tagged.text)
    write.csv(data.frame(res.mtld),file="output.csv")
  }
  </code></pre>
  
  <p>where infra is:</p>
  
  <pre><code>tableid 1, 2, 3, ... 80
  whypar "I took part because xxx", "I believe that jshfdjk", "jhsadkjhd" ... (N=350)
  </code></pre>
  
  <hr>
  
  <p>Thanks for any help</p>