3

I'm trying to put a table in rmarkdown, using datatable command from DT package. I have my table as pdf like :

enter image description here

which is not readable (very small) and it does not change if I add width/height="in px or %" in to the options list.

How could I get bigger table ?

```{r, fig.align='center', fig.pos='htb!', echo=FALSE, cache=FALSE, warning = FALSE, message = FALSE, tidy=TRUE}
library(DT)
library(webshot)
DT::datatable(cor()$AEP, options = list(dom='t',ordering=F,rowCallback = JS("function(r,d) {$(r).attr('height', '100px')}")))


```
6
  • You can pass your datatable to knitr::kable and use the package kableExtra for styling; eg, knitr::kable(dt) %>% kableExtra::kable_styling(full_width=TRUE). See the docs
    – juan
    Aug 4, 2017 at 13:30
  • @juan The number of column are too much for that, I have tried your suggestion already, but since I could not break the rows into multi-line, they don't fit to the page width unless I choose very small font which again is not readable. Aug 4, 2017 at 13:49
  • Ah, ok. Did you try kable_styling(latex_options=scale_down) instead of resizing it yourself?
    – juan
    Aug 4, 2017 at 14:08
  • @juan : Yes ! I did, but again this make the table very small ! If I could find a way that I could fix the column width and break the rows into multi lines it may help ! Aug 4, 2017 at 14:26
  • You can also adjust column width. On the other hand, you might consider using landscape mode for a very wide table.
    – juan
    Aug 4, 2017 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.