title: R: Printing random forest model to html
body: <p>I'm working on a Rmd document that I would like to compile to html using knitr package via the HTML export mechanism available in RStudio. The problem can be reproduced with the code below:</p>
  
  <p><strong><em>Example</em></strong></p>
  
  <pre><code># Set up
  rm(list = ls())
  data(airquality)
  attach(airquality)
  packs &lt;- c("randomForest", "knitr", "xtable", "xtable", "stargazer")
  lapply(packs, require, character.only=T, quietly = TRUE, warn.conflicts = FALSE)
  
  # Model
  airquality &lt;- na.roughfix(airquality)
  dummy &lt;- randomForest(Ozone ~., data = airquality)
  
  # Problem
  kable(dummy)
  xtable(dummy)
  stargazer(dummy)
  </code></pre>
  
  <p>The issue is further illustrated by the output below:</p>
  
  <p><strong><em>Output</em></strong></p>
  
  <pre><code>&gt; # Problem
  &gt; kable(dummy)
  Error in as.data.frame.default(x) : 
    cannot coerce class "c("randomForest.formula", "randomForest")" to a data.frame
  &gt; xtable(dummy)
  Error in UseMethod("xtable") : 
    no applicable method for 'xtable' applied to an object of class "c('randomForest.formula', 'randomForest')"
  &gt; stargazer(dummy)
  
  % Error: Unrecognized object type.
  </code></pre>
  
  <p>Is it possible to force the <code>randomForest</code> output into a nice html table that would be presentable in a markdown document?</p>