title: How to write a describe function output into a csv in R?
body: <p>I have some data, let's say the mtcars dataset in R , and I want to export the describe function output to a csv file in a good format.</p>
  
  <p>For the describe function output , we can use:  </p>
  
  <pre><code>install.packages(Hmisc)  
  library(Hmisc)
  mt_data = mtcars
  x = describe(mt_data)
  </code></pre>
  
  <p>Tried to write to CSV file1:</p>
  
  <pre><code>write.csv(x, file="names22.csv",row.names = F)    
  </code></pre>
  
  <p>Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : 
    cannot coerce class ""describe"" to a data.frame</p>
  
  <p>Attempt2</p>
  
  <pre><code>data = mtcars  
  x = describe(data)
  write.csv(t(as.matrix(x)), file="name2.csv") 
  </code></pre>
  
  <p>But the above command is giving the output in a very weird format.</p>
  
  <p>Expected output  </p>
  
  <pre><code>        x1   x2  x3  x4 
  mpg     12   23  758 23
  cyl     2    23  23  64
  disp    2    31  32  53
  xyz     4    21  32  23
  skjf    8    21  23  23
  </code></pre>
  
  <p>The above format is what I'm trying to achieve to write in a csv file.</p>