How to "box" the output of "summary()" in Rmarkdown

I have seen this post from

and one of the responders, Cedric, impressed me with the way he or she boxed the output of summary() command in R.

enter image description here

I understand that the user used Sweave to create such a great output.
I am curious that whether there is a way to use Knit to output to a PDF file in the similar fashion.

Thank you!

Here is an answer for HTML output.

You can change the look of the html using a custom css, and it is easy to assign a specific class for the chunk output using class.output chunk options

title: Test box output
  html_document: default

```{css, echo = FALSE}
.bordered {
  border: solid;

```{r, class.output = ".bordered"}
summary(lm(data = mtcars, mtcars[, 1] ~ mtcars[, 2]))

I let someone else gives an answer for PDFoutput. :slight_smile:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.