title: How to show formatted R output with results='asis' in rmarkdown
body: <p>Is there a way of showing formatter R output in rmarkdown/knitr when using results = 'asis'? </p>
  
  <p>An example would be the following function:</p>
  
  <pre><code>myfun &lt;- function() {
    cat("hello!\n")
    cat(c("one" = 1, "two" = 2))
  }
  </code></pre>
  
  <p>Then, this chunk will print the second <code>cat</code> on a new row:</p>
  
  <pre><code>```{r}
  myfun()
  ```
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zcKab.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zcKab.png" alt="nice printing"></a></p>
  
  <p>But this will ignore the formatting from <code>myfun</code>:</p>
  
  <pre><code>```{r, results = "asis"}
  myfun()
  ```
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OXWbV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OXWbV.png" alt="non-formatted printing"></a></p>
  
  <p>Is there a way of keeping <code>results='asis'</code> but at the same time keep the output of <code>myfun</code> formatted as intended?</p>