0

I find several threads on to change the output columns in knitr using

```{r set-options, echo=FALSE, cache=FALSE}
options(width = SOME-REALLY-BIG-VALUE)
```

in this post How to adjust the output width of RStudio Markdown output (to HTML)

This worked fine if my table is narrower than the page width. However, when my table has many columns, each line is broken and displayed like in txt file. Here is the picture to illustrate what I mean.

Before adjusting width

After adjusting width

How to adjust to make the table fill the whole width of the page and break it into parts if the page is not wide enough? Thank you.

Community
  • 1
  • 1

1 Answers1

1

Are you dead-set on using the raw output from R print? You could make it look nicer and accomplish your "table-splitting" using markdown tables with the pander package.

Hello Stack
===========

```{r echo = FALSE, results = 'asis'}
x = matrix(rnorm(160), ncol=16)
pander::pander(as.data.frame(x),split.table = 120, style = 'rmarkdown')
```
Chrisss
  • 3,211
  • 1
  • 16
  • 13
  • Thank you. I found some information about pander too. I wonder if there's a way to set a global setting. Otherwise, I have to the default knitr table is different from pander table output. – Terry Zhenning Tan Oct 05 '16 at 17:01
  • 2
    Yes, there is. Write `pander::panderOptions("table.split.table", 120)`. All following calls to `pander` will use this default whenever applicable. – Chrisss Oct 05 '16 at 17:11