title: Write a list, as seen in R console output, into a text file
body: <p>I have problem with writing a list into a text file in r. Here is my code:</p>
  
  <pre><code>library(e1071)
  mydata = read.table("TRAIN.txt", sep = ",", header = FALSE)
  model &lt;- naiveBayes(as.factor(V1) ~., data = my data)
  </code></pre>
  
  <p>and I want to write the "model" into a text file. Here is the "model" format:</p>
  
  <pre><code>A-priori probabilities:
  Y
     0        1 
  0.703125 0.296875 
  
  Conditional probabilities:
  V2
  Y         [,1]      [,2]
  0  0.1327792 1.1571522
  1 -0.1276267 0.9334735
  
  V3
  Y         [,1]      [,2]
  0 -0.2414282 1.0982461
  1 -0.2269481 0.7594525
  </code></pre>
  
  <p>and I tried the following:</p>
  
  <pre><code>write(model, "TEST.txt")
  </code></pre>
  
  <p>and got the following error:</p>
  
  <pre><code>Error in cat(list(...), file, sep, fill, labels, append) : 
  argument 1 (type 'list') cannot be handled by 'cat'
  </code></pre>
  
  <p>and then I tried</p>
  
  <pre><code>lapply(model, cat, file='test.txt', append=TRUE)
  </code></pre>
  
  <p>and got the same error. </p>