1

I have several wide tables that should fit onto an html report, but I don't know how to do it.

Consider the following example. It's rather silly I know, because I could chop the digits off, but many of my tables have string columns that are about this long and cannot be chopped:

---
title: "DT Fitting"
output: html_document
---

```{r testTable, fig.align = 'left', fig.width = 6in}
DT::datatable(datasets::euro.cross)
```

It renders an html report that looks like this:

enter image description here

Notice that I've tried using fig.align and fig.width to align or shrink the table, but they don't seem to work. Does anyone know to put this single table onto the page so as to be completely visible?

jks612
  • 1,068
  • 9
  • 19

1 Answers1

0

It looks like a previous SO post captures this.

This allows you to set the width via options(width = some number). This doesn't seem to be the ideal solution if you have multiple wide tables.

Another option is to consider, fixing the columns when setting up the datatables and enabling scrolling. Check out Section 5. They allow you to fix the first and last column, and scroll the columns in between.

Based on the Datatables link:

```{r}
      DT::datatable(datasets::euro.cross,
          extensions = 'FixedColumns',
             options = list(
                      dom = 't',
                      scrollX = TRUE,
                      fixedColumns = list(leftColumns = 2, rightColumns = 1))
                    )
```
Community
  • 1
  • 1
msubbaiah
  • 330
  • 1
  • 14