Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DT showing more rows in DT

Tags:

r

r-markdown

dt

When I run the following code I only get 1 or 2 rows of data. How can I increase the number of displayed rows? Thank you!

    ---
    title: " File Analysis"
    output:
    html_document: default
    pdf_document: default
    word_document: default
    ---

    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = FALSE,comment = NA, echo=FALSE,message= FALSE, warning = FALSE)
    ```
    **As can be seen in Table 1 below**
    ```{r echo=FALSE, message=FALSE,warning = FALSE}
    cwater<-matrix(rbinom(10*100, 1, .5), ncol=10)

    library("knitr","xtable", quietly = TRUE)
    library(DT, quietly = TRUE)
    datatable(cwater, caption = 'Table 1: This is a searchable table of the     water content.',
    class = 'cell-border stripe', filter = 'top',extensions   = 'Buttons',fillContainer=TRUE, options = list(
    pageLength = 10, autoWidth = TRUE,dom = 'Bfrtip',buttons = c  ('copy', 'print'), scrollX = TRUE, 
 selection="multiple"
    ))
    ```
like image 572
tom Avatar asked Jun 05 '17 12:06

tom


1 Answers

You need to increase the size of the container or turn off the 'fillContainer' option:

---
title: "DT Table Example"
output: 
  html_notebook:
    toc: true
    number_sections: false
    theme: united
    highlight: tango
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,comment = NA, echo=FALSE,message= FALSE, warning = FALSE)
```
**Turn off the 'fillContainer' option**
```{r echo=FALSE, message=FALSE,warning = FALSE}
cwater<-matrix(rbinom(10*100, 1, .5), ncol=10)

library("knitr","xtable", quietly = TRUE)
library(DT, quietly = TRUE)
datatable(cwater,
          caption = 'Table 1: This is a searchable table of the water content.',
          class = 'cell-border stripe', 
          filter = 'top',
          extensions = 'Buttons',
          fillContainer = FALSE, 
          options = list(pageLength = 10, 
                         autoWidth = TRUE,
                         dom = 'Bfrtip',
                         buttons = c('copy', 
                                     'print'), 
                         scrollX = TRUE, 
            selection="multiple"
          ))
```
like image 85
Davit Sargsyan Avatar answered Nov 13 '22 17:11

Davit Sargsyan